diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 33c0eb0..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/vector/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 20ab342..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/vector/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 8a4fafe..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '12 12 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -346,7 +343,7 @@ logEachMap( 'len: %2d. dtype: %7s. sum: %d.', args[ 0 ], args[ 1 ], clbk ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -409,21 +406,21 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-vector-ctor/main/LICENSE -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/ndarray/vector/float64]: https://github.com/stdlib-js/ndarray-vector-float64 +[@stdlib/ndarray/vector/float64]: https://github.com/stdlib-js/ndarray-vector-float64/tree/esm -[@stdlib/ndarray/vector/float32]: https://github.com/stdlib-js/ndarray-vector-float32 +[@stdlib/ndarray/vector/float32]: https://github.com/stdlib-js/ndarray-vector-float32/tree/esm -[@stdlib/ndarray/vector/complex128]: https://github.com/stdlib-js/ndarray-vector-complex128 +[@stdlib/ndarray/vector/complex128]: https://github.com/stdlib-js/ndarray-vector-complex128/tree/esm -[@stdlib/ndarray/vector/complex64]: https://github.com/stdlib-js/ndarray-vector-complex64 +[@stdlib/ndarray/vector/complex64]: https://github.com/stdlib-js/ndarray-vector-complex64/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.factory.js b/benchmark/benchmark.factory.js deleted file mode 100644 index 4730aca..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,318 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( format( '%s:factory', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - values = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( values[ i%values.length ] ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=float64', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=float32', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=complex128', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=complex64', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=int32', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=uint32', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=int16', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=uint16', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=int8', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=uint8', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=uint8c', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:factory:dtype=generic', pkg ), function benchmark( b ) { - var vector; - var arr; - var i; - - vector = factory( 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.factory.size.js b/benchmark/benchmark.factory.size.js deleted file mode 100644 index 1dcdbb5..0000000 --- a/benchmark/benchmark.factory.size.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes( 'real_floating_point_and_generic' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @param {string} dtype - data type -* @returns {Function} benchmark function -*/ -function createBenchmark( len, dtype ) { - var vector = factory( dtype ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var dt; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < DTYPES.length; j++ ) { - dt = DTYPES[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len, dt ); - bench( format( '%s:factory:dtype=%s,size=%d', pkg, dt, len ), f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 7ef69d1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.size.js b/benchmark/benchmark.size.js deleted file mode 100644 index 67dec1e..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes( 'real_floating_point_and_generic' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @param {string} dtype - data type -* @returns {Function} benchmark function -*/ -function createBenchmark( len, dtype ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = vector( len, dtype ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isndarrayLike( arr ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var dt; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < DTYPES.length; j++ ) { - dt = DTYPES[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len, dt ); - bench( format( '%s:dtype=%s:size=%d', pkg, dt, len ), f ); - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 863a348..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/vector/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-vector-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-vector-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-vector-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-vector-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-vector-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/vector/ctor -[production-url]: https://github.com/stdlib-js/ndarray-vector-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-vector-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-vector-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-vector-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-vector-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-vector-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-vector-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index f66c289..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import vector from '../docs/types/index'; -export = vector; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2536682..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(a){throw r=0,a}}};var N=D(function(br,I){"use strict";var W=require("@stdlib/assert-is-plain-object"),P=require("@stdlib/assert-has-own-property"),H=require("@stdlib/assert-is-boolean").isPrimitive,J=require("@stdlib/ndarray-base-assert-is-index-mode"),K=require("@stdlib/ndarray-base-assert-is-order"),B=require("@stdlib/string-format");function Q(e,r){return W(r)?P(r,"readonly")&&(e.readonly=r.readonly,!H(e.readonly))?new TypeError(B("invalid option. `%s` option must be a boolean. Option: `%s`.","readonly",e.readonly)):P(r,"mode")&&(e.mode=r.mode,!J(e.mode))?new TypeError(B("invalid option. `%s` option must be a valid index mode. Option: `%s`.","mode",e.mode)):P(r,"order")&&(e.order=r.order,!K(e.order))?new TypeError(B("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",e.order)):null:new TypeError(B("invalid argument. Options argument must be an object. Value: `%s`.",r))}I.exports=Q});var x=D(function(yr,z){"use strict";var w=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,X=require("@stdlib/assert-is-iterable-like"),Z=require("@stdlib/assert-is-collection"),T=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),j=require("@stdlib/ndarray-base-assert-is-generic-data-type"),A=require("@stdlib/ndarray-base-assert-is-binary-data-type"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),F=require("@stdlib/array-typed"),R=require("@stdlib/array-base-copy"),h=require("@stdlib/ndarray-ctor"),_=require("@stdlib/ndarray-defaults"),er=require("@stdlib/ndarray-base-strides2offset"),ar=require("@stdlib/buffer-from-arraybuffer"),M=require("@stdlib/buffer-from-array"),nr=require("@stdlib/buffer-from-buffer"),tr=require("@stdlib/array-from-iterator"),p=require("@stdlib/ndarray-base-bytes-per-element"),ir=require("@stdlib/symbol-iterator"),s=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function g(e){return rr(e,"order")?e.order:E}function b(e,r,a,n,t,u,l){var i,f,o,V,c;if(j(e))throw new TypeError(s("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return c=t,V=a*n,n<0&&(V*=-1,c-=V*p(e)),A(e)?i=ar(r,c,V):i=F(r,c,V,e),f=[a],o=[n],c=er(f,o),arguments.length>6?new h(e,i,f,o,c,u,l):new h(e,i,f,o,c,u)}function q(e,r,a){var n,t;return a===null?n={}:n=a,w(e)?(t=k(r,e),new h(r,t,[t.length],[1],0,g(n),n)):$(e)?(j(r)?t=R(e):A(r)?t=nr(e):t=F(e,r),new h(r,t,[t.length],[1],0,g(n),n)):Z(e)?(j(r)?t=R(e):A(r)?t=M(e):t=F(e,r),new h(r,t,[t.length],[1],0,g(n),n)):T(e)?b(r,e,e.byteLength/p(r),1,0,g(n),n):X(e)?(t=e[ir](),t=tr(t),A(r)?t=M(t):j(r)||(t=F(t,r)),new h(r,t,[t.length],[1],0,g(n),n)):a===null&&O(e)?(t=k(r,0),new h(r,t,[t.length],[1],0,g(e),e)):null}function ur(){var e,r,a,n,t,u,l,i;if(e=arguments.length,e===0)return l=k(v,0),new h(v,l,[l.length],[1],0,E);if(r=arguments[0],e===1){if(y(r))return q(0,r,null);if(i=q(r,v,null),i===null)throw new TypeError(s("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(a=arguments[1],e===2){if(y(r)){if(a===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",a));return q(0,r,a)}if(y(a)){if(i=q(r,a,null),i===null)throw new TypeError(s("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(a)){if(!T(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-a)/p(v),1,a,E)}if(a===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=q(r,v,a),i===null)throw new TypeError(s("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(n=arguments[2],e===3){if(y(n)){if(!T(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(a))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));return b(n,r,(r.byteLength-a)/p(n),1,a,E)}if(y(a)){if(n===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",n));if(i=q(r,a,n),i===null)throw new TypeError(s("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!T(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(a))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(w(n))return b(v,r,n,1,a,E);if(n===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,(r.byteLength-a)/p(v),1,a,g(n),n)}if(t=arguments[3],e===4){if(!T(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(a))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(w(n)){if(y(t))return b(t,r,n,1,a,E);if(!O(t))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));return b(v,r,n,1,a,g(t),t)}if(!y(n))throw new TypeError(s("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(t))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));return b(n,r,(r.byteLength-a)/p(n),1,a,g(t),t)}if(u=arguments[4],!T(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(a))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(!w(n))throw new TypeError(s("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));if(!y(t))throw new TypeError(s("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",t));if(!O(u))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(t,r,n,1,a,g(u),u)}z.exports=ur});var G=D(function(hr,Y){"use strict";var L=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,or=require("@stdlib/assert-is-iterable-like"),C=require("@stdlib/assert-is-arraybuffer"),U=require("@stdlib/assert-is-collection"),sr=require("@stdlib/ndarray-base-assert-is-data-type"),fr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),d=N(),m=x();function mr(e,r){var a,n;if(!sr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(a={},arguments.length>1&&(n=d(a,r),n))throw n;return t;function t(){var u,l,i,f,o;if(u=fr({},a),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=d(u,arguments[3]),o)throw o;return m(arguments[0],arguments[1],arguments[2],e,u)}if(l===3){if(L(arguments[2]))return m(arguments[0],arguments[1],arguments[2],e,u);if(o=d(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],f=arguments[1],L(i)){if(o=d(u,f),o)throw o;return m(i,e,u)}if(C(i)){if(L(f))return m(i,f,e,u);if(o=d(u,f),o)throw o;return m(i,e,u)}if(U(i)){if(o=d(u,f),o)throw o;return m(i,e,u)}if(o=d(u,f),o)throw o;return m(i,e,u)}if(i=arguments[0],L(i)||C(i)||U(i)||or(i))return m(i,e,u);if(o=d(u,i),o)throw o;return m(e,u)}}Y.exports=mr});var vr=require("@stdlib/utils-define-nonenumerable-read-only-property"),gr=G(),S=x();vr(S,"factory",gr);module.exports=S; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 7ca6243..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/validate.js", "../lib/main.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isIndexMode = require( '@stdlib/ndarray-base-assert-is-index-mode' );\nvar isOrder = require( '@stdlib/ndarray-base-assert-is-order' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector\n* @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions\n* @param {string} [options.order] - memory layout (either row-major or column-major)\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'readonly': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\topts.readonly = options.readonly;\n\t\tif ( !isBoolean( opts.readonly ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readonly', opts.readonly ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a valid index mode. Option: `%s`.', 'mode', opts.mode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'order' ) ) {\n\t\topts.order = options.order;\n\t\tif ( !isOrder( opts.order ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a memory layout. Option: `%s`.', 'order', opts.order ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isIterableLike = require( '@stdlib/assert-is-iterable-like' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar isGenericDataType = require( '@stdlib/ndarray-base-assert-is-generic-data-type' );\nvar isBinaryDataType = require( '@stdlib/ndarray-base-assert-is-binary-data-type' );\nvar isDataType = require( '@stdlib/ndarray-base-assert-is-data-type' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar typedarray = require( '@stdlib/array-typed' );\nvar copy = require( '@stdlib/array-base-copy' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar defaults = require( '@stdlib/ndarray-defaults' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar arraybuffer2buffer = require( '@stdlib/buffer-from-arraybuffer' );\nvar array2buffer = require( '@stdlib/buffer-from-array' );\nvar copyBuffer = require( '@stdlib/buffer-from-buffer' );\nvar iterator2array = require( '@stdlib/array-from-iterator' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar DEFAULT_ORDER = defaults.get( 'order' );\n\n\n// FUNCTIONS //\n\n/**\n* Resolves the order of the output vector.\n*\n* @private\n* @param {*} options - options argument\n* @returns {string} order\n*/\nfunction resolveOrder( options ) {\n\tif ( hasOwnProp( options, 'order' ) ) {\n\t\treturn options.order;\n\t}\n\treturn DEFAULT_ORDER;\n}\n\n/**\n* Creates a one-dimensional ndarray from an ArrayBuffer.\n*\n* @private\n* @param {string} dtype - data type\n* @param {ArrayBuffer} buffer - ArrayBuffer\n* @param {NonNegativeInteger} length - number of indexed elements\n* @param {integer} stride - stride length (in units of elements)\n* @param {NonNegativeInteger} byteOffset - byte offset of the first indexed element\n* @param {string} order - memory layout (either row-major or column-major)\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions\n* @throws {TypeError} data type must be compatible with the provided ArrayBuffer\n* @returns {ndarray} one-dimensional ndarray\n*\n* @example\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 4, 1, 0, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* @example\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float32', buf, 8, 1, 0, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 8\n*\n* @example\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 4, -1, 32, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* @example\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 2, -1, 24, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*/\nfunction arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) { // TODO: replace with `@stdlib/ndarray/from-arraybuffer`\n\tvar buf;\n\tvar sh;\n\tvar st;\n\tvar N;\n\tvar o;\n\n\tif ( isGenericDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.', dtype ) );\n\t}\n\to = byteOffset;\n\n\t// Compute the number of underlying elements across which the vector view will span:\n\tN = length * stride;\n\n\t// Adjust the byte offset to point to the element marking the beginning of the view:\n\tif ( stride < 0 ) { // TODO: the following is effectively unreachable code, as provided strides are never anything other than unity; however, we keep this around in the event that we want to extract this function to a separate package and would like to maintain generality\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype ); // FIXME: this is incorrect for the general case\n\t}\n\t// Create the underlying ndarray buffer:\n\tif ( isBinaryDataType( dtype ) ) {\n\t\tbuf = arraybuffer2buffer( buffer, o, N );\n\t} else {\n\t\tbuf = typedarray( buffer, o, N, dtype );\n\t}\n\t// Resolve ndarray meta data:\n\tsh = [ length ];\n\tst = [ stride ];\n\to = strides2offset( sh, st );\n\n\t// Return a new ndarray instance:\n\tif ( arguments.length > 6 ) {\n\t\treturn new ndarray( dtype, buf, sh, st, o, order, options );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, o, order );\n}\n\n/**\n* Returns a vector having a specified data type.\n*\n* @private\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Buffer|Iterable|Options)} arg - length, typed array, array-like object, buffer, iterable, or options object\n* @param {string} dtype - data type\n* @param {(Options|null)} options - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions\n* @returns {(ndarray|null)} one-dimensional ndarray\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var v = vectorWithDType( 10, 'float64', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 10\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'generic'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vectorWithDType( buf, 'float64', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var v = vectorWithDType( {}, 'float64', null );\n* // returns \n*\n* var len = numel( v );\n* // returns 0\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var array2iterator = require( '@stdlib/array-to-iterator' );\n*\n* var v = vectorWithDType( array2iterator( [ 1, 2, 3, 4 ] ), 'generic', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'generic'\n*/\nfunction vectorWithDType( arg, dtype, options ) {\n\tvar opts;\n\tvar buf;\n\n\t// Note: in all of the following, we delegate option validation to the ndarray constructor...\n\tif ( options === null ) {\n\t\topts = {};\n\t} else {\n\t\topts = options;\n\t}\n\t// Case: vector( length )\n\tif ( isNonNegativeInteger( arg ) ) {\n\t\tbuf = buffer( dtype, arg );\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( Buffer )\n\tif ( isBuffer( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = copy( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = copyBuffer( arg );\n\t\t} else {\n\t\t\tbuf = typedarray( arg, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( collection )\n\tif ( isCollection( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = copy( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( arg ); // note: we assume that `arg` is an array of octets\n\t\t} else {\n\t\t\tbuf = typedarray( arg, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( ArrayBuffer )\n\tif ( isArrayBuffer( arg ) ) {\n\t\treturn arraybuffer2vector( dtype, arg, arg.byteLength/bytesPerElement( dtype ), 1, 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( Iterable )\n\tif ( isIterableLike( arg ) ) {\n\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\tbuf = iterator2array( buf );\n\t\tif ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( buf );\n\t\t} else if ( !isGenericDataType( dtype ) ) {\n\t\t\tbuf = typedarray( buf, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( options )\n\tif ( options === null && isPlainObject( arg ) ) {\n\t\tbuf = buffer( dtype, 0 );\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( arg ), arg );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Creates a vector (i.e., a one-dimensional ndarray).\n*\n* ## Notes\n*\n* - This API is intended to match the conventions of `@stdlib/array/typed`, which has a similar signature.\n*\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype='float64'] - data type\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions\n* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major)\n* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, data type, or options object\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} one-dimensional ndarray\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var arr = vector();\n* // returns \n*\n* var len = numel( arr );\n* // returns 0\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var arr = vector( 2 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var arr = vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var arr = vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = vector( buf );\n* // returns \n*\n* var len = numel( arr );\n* // returns 4\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = vector( buf, 16 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = vector( buf, 16, 2 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*/\nfunction vector() {\n\tvar nargs;\n\tvar arg0;\n\tvar arg1;\n\tvar arg2;\n\tvar arg3;\n\tvar arg4;\n\tvar buf;\n\tvar out;\n\n\tnargs = arguments.length;\n\n\t// Case: vector()\n\tif ( nargs === 0 ) {\n\t\tbuf = buffer( DEFAULT_DTYPE, 0 );\n\t\treturn new ndarray( DEFAULT_DTYPE, buf, [ buf.length ], [ 1 ], 0, DEFAULT_ORDER );\n\t}\n\targ0 = arguments[ 0 ];\n\n\t// Case: vector( arg0 );\n\tif ( nargs === 1 ) {\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\treturn vectorWithDType( 0, arg0, null );\n\t\t}\n\t\tout = vectorWithDType( arg0, DEFAULT_DTYPE, null );\n\t\tif ( out === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.', arg0 ) );\n\t\t}\n\t\treturn out;\n\t}\n\targ1 = arguments[ 1 ];\n\n\t// Case: vector( arg0, arg1 )\n\tif ( nargs === 2 ) {\n\t\t// Case: vector( dtype, options )\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\tif ( arg1 === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg1 ) );\n\t\t\t}\n\t\t\treturn vectorWithDType( 0, arg0, arg1 );\n\t\t}\n\t\t// Case: vector( arg0, dtype )\n\t\tif ( isDataType( arg1 ) ) {\n\t\t\tout = vectorWithDType( arg0, arg1, null );\n\t\t\tif ( out === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset )\n\t\tif ( isNonNegativeInteger( arg1 ) ) {\n\t\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( arg0, options )\n\t\tif ( arg1 === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg1 ) );\n\t\t}\n\t\tout = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 );\n\t\tif ( out === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t}\n\t\treturn out;\n\t}\n\targ2 = arguments[ 2 ];\n\n\t// Case: vector( arg0, arg1, arg2 )\n\tif ( nargs === 3 ) {\n\t\t// Case: vector( ArrayBuffer, byteOffset, dtype )\n\t\tif ( isDataType( arg2 ) ) {\n\t\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( arg0, dtype, options )\n\t\tif ( isDataType( arg1 ) ) {\n\t\t\tif ( arg2 === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) );\n\t\t\t}\n\t\t\tout = vectorWithDType( arg0, arg1, arg2 );\n\t\t\tif ( out === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, arg2 )\n\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\tif ( isNonNegativeInteger( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, options )\n\t\tif ( arg2 === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t}\n\targ3 = arguments[ 3 ];\n\n\t// Case: vector( ArrayBuffer, byteOffset, arg2, arg3 )\n\tif ( nargs === 4 ) {\n\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length, dtype )\n\t\tif ( isNonNegativeInteger( arg2 ) ) {\n\t\t\tif ( isDataType( arg3 ) ) {\n\t\t\t\treturn arraybuffer2vector( arg3, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, length, options )\n\t\t\tif ( !isPlainObject( arg3 ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, dtype, options )\n\t\tif ( !isDataType( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.', arg2 ) );\n\t\t}\n\t\tif ( !isPlainObject( arg3 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) );\n\t\t}\n\t\treturn arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 );\n\t}\n\targ4 = arguments[ 4 ];\n\n\t// Case: vector( ArrayBuffer, byteOffset, length, dtype, options )\n\tif ( !isArrayBuffer( arg0 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) );\n\t}\n\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) );\n\t}\n\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) );\n\t}\n\tif ( !isDataType( arg3 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.', arg3 ) );\n\t}\n\tif ( !isPlainObject( arg4 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg4 ) );\n\t}\n\treturn arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 );\n}\n\n\n// EXPORTS //\n\nmodule.exports = vector;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isIterableLike = require( '@stdlib/assert-is-iterable-like' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isDataType = require( '@stdlib/ndarray-base-assert-is-data-type' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar validate = require( './validate.js' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating a vector (i.e., a one-dimensional ndarray).\n*\n* @param {string} dtype - data type\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector by default\n* @param {string} [options.mode='throw'] - specifies the default behavior when handling indices which exceed vector dimensions\n* @param {string} [options.order='row-major'] - default memory layout (either row-major or column-major)\n* @throws {TypeError} first argument must be a supported data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for creating a vector\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var arr = new Float32Vector( [ 1, 2, 3 ] );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var arr = new Float32Vector( 3 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf, 4 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf, 4, 1 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 1\n*/\nfunction factory( dtype, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !isDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn vector;\n\n\t/**\n\t* Creates a vector (i.e., a one-dimensional ndarray).\n\t*\n\t* @private\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector\n\t* @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions\n\t* @param {string} [options.order] - memory layout (either row-major or column-major)\n\t* @throws {Error} unexpected error\n\t* @returns {ndarray} one-dimensional ndarray\n\t*/\n\tfunction vector() {\n\t\tvar options;\n\t\tvar nargs;\n\t\tvar arg0;\n\t\tvar arg1;\n\t\tvar err;\n\n\t\toptions = objectAssign( {}, opts );\n\t\tnargs = arguments.length;\n\n\t\t// Case: vector()\n\t\tif ( nargs === 0 ) {\n\t\t\treturn main( dtype, options );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length, options )\n\t\tif ( nargs > 3 ) {\n\t\t\terr = validate( options, arguments[ 3 ] );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, arg2 )\n\t\tif ( nargs === 3 ) {\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\t\tif ( isNonNegativeInteger( arguments[ 2 ] ) ) {\n\t\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, options )\n\t\t\terr = validate( options, arguments[ 2 ] );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], dtype, options );\n\t\t}\n\t\t// Case: vector( arg0, arg1 )\n\t\tif ( nargs === 2 ) {\n\t\t\targ0 = arguments[ 0 ];\n\t\t\targ1 = arguments[ 1 ];\n\n\t\t\t// Case: vector( length, options )\n\t\t\tif ( isNonNegativeInteger( arg0 ) ) {\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, arg1 )\n\t\t\tif ( isArrayBuffer( arg0 ) ) {\n\t\t\t\t// Case: vector( ArrayBuffer, byteOffset )\n\t\t\t\tif ( isNonNegativeInteger( arg1 ) ) {\n\t\t\t\t\treturn main( arg0, arg1, dtype, options );\n\t\t\t\t}\n\t\t\t\t// Case: vector( ArrayBuffer, options )\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( collection, options )\n\t\t\tif ( isCollection( arg0 ) ) {\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( iterable, options )\n\t\t\terr = validate( options, arg1 );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arg0, dtype, options );\n\t\t}\n\t\t// nargs === 1\n\t\targ0 = arguments[ 0 ];\n\n\t\t// Case: vector( length|ArrayBuffer|Collection|Iterable )\n\t\tif (\n\t\t\tisNonNegativeInteger( arg0 ) ||\n\t\t\tisArrayBuffer( arg0 ) ||\n\t\t\tisCollection( arg0 ) ||\n\t\t\tisIterableLike( arg0 )\n\t\t) {\n\t\t\treturn main( arg0, dtype, options );\n\t\t}\n\t\t// Case: vector( options )\n\t\terr = validate( options, arg0 );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\treturn main( dtype, options );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a vector (i.e., a one-dimensional ndarray).\n*\n* @module @stdlib/ndarray-vector-ctor\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = vector();\n* // returns \n*\n* var len = numel( v );\n* // returns 0\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = vector( 2 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vector( buf );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vector( buf, 16 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var getDType = require( '@stdlib/ndarray-dtype' );\n* var numel = require( '@stdlib/ndarray-numel' );\n* var vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = vector( buf, 16, 2 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar factory = require( './factory.js' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"factory\": \"main.factory\" }\n"], - "mappings": "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", - "names": ["require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIndexMode", "isOrder", "format", "validate", "opts", "options", "require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isIterableLike", "isCollection", "isArrayBuffer", "isPlainObject", "isBuffer", "isGenericDataType", "isBinaryDataType", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "resolveOrder", "options", "arraybuffer2vector", "dtype", "length", "stride", "byteOffset", "order", "buf", "sh", "st", "N", "o", "vectorWithDType", "arg", "opts", "vector", "nargs", "arg0", "arg1", "arg2", "arg3", "arg4", "out", "require_factory", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isIterableLike", "isArrayBuffer", "isCollection", "isDataType", "objectAssign", "format", "validate", "main", "factory", "dtype", "options", "opts", "err", "vector", "nargs", "arg0", "arg1", "setReadOnly", "factory", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 901d063..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,246 +0,0 @@ - -{{alias}}( [dtype][, options] ) - Returns a one-dimensional ndarray. - - Parameters - ---------- - dtype: string (optional) - Underlying data type. Default: 'float64'. - - options: Object (optional) - Options. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - A one-dimensional ndarray. - - Examples - -------- - > var arr = {{alias}}() - - > var dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float64' - > arr = {{alias}}( 'float32' ) - - > dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float32' - - -{{alias}}( length[, dtype][, options] ) - Returns a one-dimensional ndarray having a specified length. - - Parameters - ---------- - length: integer - Number of elements. - - dtype: string (optional) - Underlying data type. Default: 'float64'. - - options: Object (optional) - Options. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - A one-dimensional ndarray. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > var dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float64' - > var len = {{alias:@stdlib/ndarray/numel}}( arr ) - 5 - > arr = {{alias}}( 5, 'float32' ) - - > dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float32' - > len = {{alias:@stdlib/ndarray/numel}}( arr ) - 5 - - -{{alias}}( obj[, dtype][, options] ) - Creates a one-dimensional ndarray from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate an ndarray. - - dtype: string (optional) - Underlying data type. Default: 'float64'. - - options: Object (optional) - Options. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - A one-dimensional ndarray. - - Examples - -------- - > var v = [ 0.5, 0.5, 0.5 ]; - > var arr = {{alias}}( v, 'float32' ) - - > var dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float32' - > var len = {{alias:@stdlib/ndarray/numel}}( arr ) - 3 - - -{{alias}}( buffer[, byteOffset[, length]][, dtype][, options] ) - Returns a one-dimensional ndarray view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first indexed - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Underlying data type. Default: 'float64'. - - options: Object (optional) - Options. - - options.order: string (optional) - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies how to handle indices which exceed array dimensions. If equal - to 'throw', an ndarray instance throws an error when an index exceeds - array dimensions. If equal to 'normalize', an ndarray instance - normalizes negative indices and throws an error when an index exceeds - array dimensions. If equal to 'wrap', an ndarray instance wraps around - indices exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', an ndarray instance sets an index exceeding array dimensions - to either `0` (minimum index) or the maximum index. Default: 'throw'. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only. Default: false. - - Returns - ------- - out: ndarray - A one-dimensional ndarray. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - - > var dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float32' - > var len = {{alias:@stdlib/ndarray/numel}}( arr ) - 4 - - -{{alias}}.factory( dtype[, options] ) - Returns a function for creating a one-dimensional ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - options: Object (optional) - Options. - - options.order: string (optional) - Specifies whether the default memory layout should be row-major (C- - style) or column-major (Fortran-style). Default: 'row-major'. - - options.mode: string (optional) - Specifies the default behavior when handling indices which exceed array - dimensions. If equal to 'throw', an ndarray instance throws an error - when an index exceeds array dimensions. If equal to 'normalize', an - ndarray instance normalizes negative indices and throws an error when an - index exceeds array dimensions. If equal to 'wrap', an ndarray instance - wraps around indices exceeding array dimensions using modulo arithmetic. - If equal to 'clamp', an ndarray instance sets an index exceeding array - dimensions to either `0` (minimum index) or the maximum index. Default: - 'throw'. - - options.readonly: boolean (optional) - Boolean indicating whether an array should be read-only by default. - Default: false. - - Returns - ------- - fcn: Function - Function for creating a one-dimensional ndarray. - - Examples - -------- - > var f = {{alias}}.factory( 'float32' ); - > var arr = f() - - > var dt = {{alias:@stdlib/ndarray/dtype}}( arr ) - 'float32' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 653b426..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,154 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import vector = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - vector(); // $ExpectType float64ndarray - vector( {} ); // $ExpectType float64ndarray - - vector( 10 ); // $ExpectType float64ndarray - vector( 10, {} ); // $ExpectType float64ndarray - - vector( [ 1, 2, 3 ] ); // $ExpectType float64ndarray - vector( [ 1, 2, 3 ], {} ); // $ExpectType float64ndarray - - vector( new ArrayBuffer( 10 ) ); // $ExpectType float64ndarray - vector( new ArrayBuffer( 10 ), {} ); // $ExpectType float64ndarray - - vector( new ArrayBuffer( 10 ), 8 ); // $ExpectType float64ndarray - vector( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType float64ndarray - - vector( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType float64ndarray - vector( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType float64ndarray - - vector( 'float32' ); // $ExpectType float32ndarray - vector( 'float32', {} ); // $ExpectType float32ndarray - - vector( 10, 'float32' ); // $ExpectType float32ndarray - vector( 10, 'float32', {} ); // $ExpectType float32ndarray - - vector( [ 1, 2, 3 ], 'int32' ); // $ExpectType int32ndarray - vector( [ 1, 2, 3 ], 'int32', {} ); // $ExpectType int32ndarray - - vector( new ArrayBuffer( 10 ), 'int32' ); // $ExpectType int32ndarray - vector( new ArrayBuffer( 10 ), 'int32', {} ); // $ExpectType int32ndarray - - vector( new ArrayBuffer( 10 ), 8, 'float32' ); // $ExpectType float32ndarray - vector( new ArrayBuffer( 10 ), 8, 'float32', {} ); // $ExpectType float32ndarray - - vector( new ArrayBuffer( 10 ), 8, 0, 'float32' ); // $ExpectType float32ndarray - vector( new ArrayBuffer( 10 ), 8, 0, 'float32', {} ); // $ExpectType float32ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, iterable, or options object... -{ - vector( true ); // $ExpectError - vector( false ); // $ExpectError - vector( null ); // $ExpectError - vector( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - vector( buf, 8, 2, 'int32', {}, {} ); // $ExpectError -} - -// Attached the main export is a `factory` method which returns a function... -{ - vector.factory( 'float64' ); // $ExpectType TypedVector<"float64"> - vector.factory( 'float32' ); // $ExpectType TypedVector<"float32"> -} - -// The `factory` method returns an ndarray... -{ - const f1 = vector.factory( 'float64' ); - - f1(); // $ExpectType float64ndarray - f1( {} ); // $ExpectType float64ndarray - - f1( 10 ); // $ExpectType float64ndarray - f1( 10, {} ); // $ExpectType float64ndarray - - f1( [ 1, 2, 3 ] ); // $ExpectType float64ndarray - f1( [ 1, 2, 3 ], {} ); // $ExpectType float64ndarray - - f1( new ArrayBuffer( 10 ) ); // $ExpectType float64ndarray - f1( new ArrayBuffer( 10 ), {} ); // $ExpectType float64ndarray - - f1( new ArrayBuffer( 10 ), 8 ); // $ExpectType float64ndarray - f1( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType float64ndarray - - f1( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType float64ndarray - f1( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType float64ndarray - - const f2 = vector.factory( 'float32' ); - - f2(); // $ExpectType float32ndarray - f2( {} ); // $ExpectType float32ndarray - - f2( 10 ); // $ExpectType float32ndarray - f2( 10, {} ); // $ExpectType float32ndarray - - f2( [ 1, 2, 3 ] ); // $ExpectType float32ndarray - f2( [ 1, 2, 3 ], {} ); // $ExpectType float32ndarray - - f2( new ArrayBuffer( 10 ) ); // $ExpectType float32ndarray - f2( new ArrayBuffer( 10 ), {} ); // $ExpectType float32ndarray - - f2( new ArrayBuffer( 10 ), 8 ); // $ExpectType float32ndarray - f2( new ArrayBuffer( 10 ), 8, {} ); // $ExpectType float32ndarray - - f2( new ArrayBuffer( 10 ), 8, 0 ); // $ExpectType float32ndarray - f2( new ArrayBuffer( 10 ), 8, 0, {} ); // $ExpectType float32ndarray - - const f3 = vector.factory( 'generic' ); - - f3(); // $ExpectType genericndarray - f3( {} ); // $ExpectType genericndarray - - f3( 10 ); // $ExpectType genericndarray - f3( 10, {} ); // $ExpectType genericndarray - - f3( [ 1, 2, 3 ] ); // $ExpectType genericndarray - f3( [ 1, 2, 3 ], {} ); // $ExpectType genericndarray -} - -// The compiler throws an error if the function returned by the `factory` method is provided a first argument which is not a data type, number, array-like object, iterable, or options object... -{ - const f = vector.factory( 'float64' ); - - f( true ); // $ExpectError - f( false ); // $ExpectError - f( null ); // $ExpectError - f( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments... -{ - const f = vector.factory( 'float64' ); - - const buf = new ArrayBuffer( 32 ); - f( buf, 8, 2, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 6f22d50..0000000 --- a/examples/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var cartesianProduct = require( '@stdlib/array-cartesian-product' ); -var unzip = require( '@stdlib/utils-unzip' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ); -var sum = require( '@stdlib/blas-ext-sum' ); -var logEachMap = require( '@stdlib/console-log-each-map' ); -var vector = require( './../lib' ); - -// Create an array of random array lengths: -var lens = discreteUniform( 10, 5, 15, { - 'dtype': 'int32' -}); - -// Resolve a list of supported ndarray integer-valued data types: -var dts = dtypes( 'integer_and_generic' ); - -// Create length-dtype pairs: -var pairs = cartesianProduct( lens, dts ); - -// Split the pairs into individual arguments: -var args = unzip( pairs ); - -// Define a callback to create a random vector and return the sum of all vector elements: -function clbk( len, dtype ) { - var x = vector( discreteUniform( len, 0, 100 ), dtype ); - return sum( x ).get(); -} - -// Apply the callback and print the results: -logEachMap( 'len: %2d. dtype: %7s. sum: %d.', args[ 0 ], args[ 1 ], clbk ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 76dd82c..6b31ee5 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fe6a844 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-data-type@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-generic-data-type@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-binary-data-type@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function k(r,e){return l(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(d("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(d("invalid option. `%s` option must be a valid index mode. Option: `%s`.","mode",r.mode)):a(e,"order")&&(r.order=e.order,!u(r.order))?new TypeError(d("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(d("null2V",e))}var A=g.get("dtypes.default"),L=g.get("order");function C(r){return a(r,"order")?r.order:L}function z(r,e,t,n,s,i,o){var l,a,m,f,u;if(h(r))throw new TypeError(d("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=s,f=t*n,n<0&&(u-=(f*=-1)*B(r)),l=y(r)?x(e,u,f):b(e,u,f,r),u=c(a=[t],m=[n]),arguments.length>6?new w(r,l,a,m,u,i,o):new w(r,l,a,m,u,i)}function O(r,i,o){var d,a;return d=null===o?{}:o,e(r)?(a=j(i,r),new w(i,a,[a.length],[1],0,C(d),d)):p(r)?(a=h(i)?v(r):y(i)?E(r):b(r,i),new w(i,a,[a.length],[1],0,C(d),d)):s(r)?(a=h(i)?v(r):y(i)?T(r):b(r,i),new w(i,a,[a.length],[1],0,C(d),d)):n(r)?z(i,r,r.byteLength/B(i),1,0,C(d),d):t(r)?(a=r[F](),a=V(a),y(i)?a=T(a):h(i)||(a=b(a,i)),new w(i,a,[a.length],[1],0,C(d),d)):null===o&&l(r)?(a=j(i,0),new w(i,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,s,o,a,m,f,u;if(0===(r=arguments.length))return f=j(A,0),new w(A,f,[f.length],[1],0,L);if(t=arguments[0],1===r){if(i(t))return O(0,t,null);if(null===(u=O(t,A,null)))throw new TypeError(d("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(s=arguments[1],2===r){if(i(t)){if(null===s)throw new TypeError(d("null2V",s));return O(0,t,s)}if(i(s)){if(null===(u=O(t,s,null)))throw new TypeError(d("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(s)){if(!n(t))throw new TypeError(d("null2B",t));return z(A,t,(t.byteLength-s)/B(A),1,s,L)}if(null===s)throw new TypeError(d("null2V",s));if(null===(u=O(t,A,s)))throw new TypeError(d("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(o=arguments[2],3===r){if(i(o)){if(!n(t))throw new TypeError(d("null2B",t));if(!e(s))throw new TypeError(d("null2C",s));return z(o,t,(t.byteLength-s)/B(o),1,s,L)}if(i(s)){if(null===o)throw new TypeError(d("null2V",o));if(null===(u=O(t,s,o)))throw new TypeError(d("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(!n(t))throw new TypeError(d("null2B",t));if(!e(s))throw new TypeError(d("null2C",s));if(e(o))return z(A,t,o,1,s,L);if(null===o)throw new TypeError(d("null2V",o));return z(A,t,(t.byteLength-s)/B(A),1,s,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(d("null2B",t));if(!e(s))throw new TypeError(d("null2C",s));if(e(o)){if(i(a))return z(a,t,o,1,s,L);if(!l(a))throw new TypeError(d("null2V",a));return z(A,t,o,1,s,C(a),a)}if(!i(o))throw new TypeError(d("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!l(a))throw new TypeError(d("null2V",a));return z(o,t,(t.byteLength-s)/B(o),1,s,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(d("null2B",t));if(!e(s))throw new TypeError(d("null2C",s));if(!e(o))throw new TypeError(d("null2F",o));if(!i(a))throw new TypeError(d("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!l(m))throw new TypeError(d("null2V",m));return z(a,t,o,1,s,C(m),m)}function P(r,l){var a,m;if(!i(r))throw new TypeError(d("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=k(a,l)))throw m;return function(){var i,d,l,m,f;if(i=o({},a),d=arguments.length,0===d)return M(r,i);if(d>3){if(f=k(i,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,i)}if(3===d){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,i);if(f=k(i,arguments[2]))throw f;return M(arguments[0],arguments[1],r,i)}if(2===d){if(m=arguments[1],e(l=arguments[0])){if(f=k(i,m))throw f;return M(l,r,i)}if(n(l)){if(e(m))return M(l,m,r,i);if(f=k(i,m))throw f;return M(l,r,i)}if(s(l)){if(f=k(i,m))throw f;return M(l,r,i)}if(f=k(i,m))throw f;return M(l,r,i)}if(l=arguments[0],e(l)||n(l)||s(l)||t(l))return M(l,r,i);if(f=k(i,l),f)throw f;return M(r,i)}}r(M,"factory",P);export{M as default,P as factory}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9c2b51d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport isIndexMode from '@stdlib/ndarray-base-assert-is-index-mode';\nimport isOrder from '@stdlib/ndarray-base-assert-is-order';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector\n* @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions\n* @param {string} [options.order] - memory layout (either row-major or column-major)\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'readonly': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\topts.readonly = options.readonly;\n\t\tif ( !isBoolean( opts.readonly ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'readonly', opts.readonly ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a valid index mode. Option: `%s`.', 'mode', opts.mode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'order' ) ) {\n\t\topts.order = options.order;\n\t\tif ( !isOrder( opts.order ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a memory layout. Option: `%s`.', 'order', opts.order ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isIterableLike from '@stdlib/assert-is-iterable-like';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isPlainObject from '@stdlib/assert-is-plain-object';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport isGenericDataType from '@stdlib/ndarray-base-assert-is-generic-data-type';\nimport isBinaryDataType from '@stdlib/ndarray-base-assert-is-binary-data-type';\nimport isDataType from '@stdlib/ndarray-base-assert-is-data-type';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport buffer from '@stdlib/ndarray-base-buffer';\nimport typedarray from '@stdlib/array-typed';\nimport copy from '@stdlib/array-base-copy';\nimport ndarray from '@stdlib/ndarray-ctor';\nimport defaults from '@stdlib/ndarray-defaults';\nimport strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport arraybuffer2buffer from '@stdlib/buffer-from-arraybuffer';\nimport array2buffer from '@stdlib/buffer-from-array';\nimport copyBuffer from '@stdlib/buffer-from-buffer';\nimport iterator2array from '@stdlib/array-from-iterator';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar DEFAULT_ORDER = defaults.get( 'order' );\n\n\n// FUNCTIONS //\n\n/**\n* Resolves the order of the output vector.\n*\n* @private\n* @param {*} options - options argument\n* @returns {string} order\n*/\nfunction resolveOrder( options ) {\n\tif ( hasOwnProp( options, 'order' ) ) {\n\t\treturn options.order;\n\t}\n\treturn DEFAULT_ORDER;\n}\n\n/**\n* Creates a one-dimensional ndarray from an ArrayBuffer.\n*\n* @private\n* @param {string} dtype - data type\n* @param {ArrayBuffer} buffer - ArrayBuffer\n* @param {NonNegativeInteger} length - number of indexed elements\n* @param {integer} stride - stride length (in units of elements)\n* @param {NonNegativeInteger} byteOffset - byte offset of the first indexed element\n* @param {string} order - memory layout (either row-major or column-major)\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions\n* @throws {TypeError} data type must be compatible with the provided ArrayBuffer\n* @returns {ndarray} one-dimensional ndarray\n*\n* @example\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 4, 1, 0, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* @example\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float32', buf, 8, 1, 0, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 8\n*\n* @example\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 4, -1, 32, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* @example\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = arraybuffer2vector( 'float64', buf, 2, -1, 24, 'row-major' );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*/\nfunction arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) { // TODO: replace with `@stdlib/ndarray/from-arraybuffer`\n\tvar buf;\n\tvar sh;\n\tvar st;\n\tvar N;\n\tvar o;\n\n\tif ( isGenericDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.', dtype ) );\n\t}\n\to = byteOffset;\n\n\t// Compute the number of underlying elements across which the vector view will span:\n\tN = length * stride;\n\n\t// Adjust the byte offset to point to the element marking the beginning of the view:\n\tif ( stride < 0 ) { // TODO: the following is effectively unreachable code, as provided strides are never anything other than unity; however, we keep this around in the event that we want to extract this function to a separate package and would like to maintain generality\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype ); // FIXME: this is incorrect for the general case\n\t}\n\t// Create the underlying ndarray buffer:\n\tif ( isBinaryDataType( dtype ) ) {\n\t\tbuf = arraybuffer2buffer( buffer, o, N );\n\t} else {\n\t\tbuf = typedarray( buffer, o, N, dtype );\n\t}\n\t// Resolve ndarray meta data:\n\tsh = [ length ];\n\tst = [ stride ];\n\to = strides2offset( sh, st );\n\n\t// Return a new ndarray instance:\n\tif ( arguments.length > 6 ) {\n\t\treturn new ndarray( dtype, buf, sh, st, o, order, options );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, o, order );\n}\n\n/**\n* Returns a vector having a specified data type.\n*\n* @private\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Buffer|Iterable|Options)} arg - length, typed array, array-like object, buffer, iterable, or options object\n* @param {string} dtype - data type\n* @param {(Options|null)} options - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions\n* @returns {(ndarray|null)} one-dimensional ndarray\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var v = vectorWithDType( 10, 'float64', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 10\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'generic'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vectorWithDType( buf, 'float64', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var v = vectorWithDType( {}, 'float64', null );\n* // returns \n*\n* var len = numel( v );\n* // returns 0\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import array2iterator from '@stdlib/array-to-iterator';\n*\n* var v = vectorWithDType( array2iterator( [ 1, 2, 3, 4 ] ), 'generic', {} );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'generic'\n*/\nfunction vectorWithDType( arg, dtype, options ) {\n\tvar opts;\n\tvar buf;\n\n\t// Note: in all of the following, we delegate option validation to the ndarray constructor...\n\tif ( options === null ) {\n\t\topts = {};\n\t} else {\n\t\topts = options;\n\t}\n\t// Case: vector( length )\n\tif ( isNonNegativeInteger( arg ) ) {\n\t\tbuf = buffer( dtype, arg );\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( Buffer )\n\tif ( isBuffer( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = copy( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = copyBuffer( arg );\n\t\t} else {\n\t\t\tbuf = typedarray( arg, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( collection )\n\tif ( isCollection( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = copy( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( arg ); // note: we assume that `arg` is an array of octets\n\t\t} else {\n\t\t\tbuf = typedarray( arg, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( ArrayBuffer )\n\tif ( isArrayBuffer( arg ) ) {\n\t\treturn arraybuffer2vector( dtype, arg, arg.byteLength/bytesPerElement( dtype ), 1, 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( Iterable )\n\tif ( isIterableLike( arg ) ) {\n\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\tbuf = iterator2array( buf );\n\t\tif ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( buf );\n\t\t} else if ( !isGenericDataType( dtype ) ) {\n\t\t\tbuf = typedarray( buf, dtype );\n\t\t}\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts );\n\t}\n\t// Case: vector( options )\n\tif ( options === null && isPlainObject( arg ) ) {\n\t\tbuf = buffer( dtype, 0 );\n\t\treturn new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( arg ), arg );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Creates a vector (i.e., a one-dimensional ndarray).\n*\n* ## Notes\n*\n* - This API is intended to match the conventions of `@stdlib/array/typed`, which has a similar signature.\n*\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype='float64'] - data type\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector\n* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions\n* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major)\n* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, data type, or options object\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} one-dimensional ndarray\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var arr = vector();\n* // returns \n*\n* var len = numel( arr );\n* // returns 0\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var arr = vector( 2 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var arr = vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var arr = vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = vector( buf );\n* // returns \n*\n* var len = numel( arr );\n* // returns 4\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = vector( buf, 16 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = vector( buf, 16, 2 );\n* // returns \n*\n* var len = numel( arr );\n* // returns 2\n*\n* var dt = getDType( arr );\n* // returns 'float64'\n*/\nfunction vector() {\n\tvar nargs;\n\tvar arg0;\n\tvar arg1;\n\tvar arg2;\n\tvar arg3;\n\tvar arg4;\n\tvar buf;\n\tvar out;\n\n\tnargs = arguments.length;\n\n\t// Case: vector()\n\tif ( nargs === 0 ) {\n\t\tbuf = buffer( DEFAULT_DTYPE, 0 );\n\t\treturn new ndarray( DEFAULT_DTYPE, buf, [ buf.length ], [ 1 ], 0, DEFAULT_ORDER );\n\t}\n\targ0 = arguments[ 0 ];\n\n\t// Case: vector( arg0 );\n\tif ( nargs === 1 ) {\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\treturn vectorWithDType( 0, arg0, null );\n\t\t}\n\t\tout = vectorWithDType( arg0, DEFAULT_DTYPE, null );\n\t\tif ( out === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.', arg0 ) );\n\t\t}\n\t\treturn out;\n\t}\n\targ1 = arguments[ 1 ];\n\n\t// Case: vector( arg0, arg1 )\n\tif ( nargs === 2 ) {\n\t\t// Case: vector( dtype, options )\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\tif ( arg1 === null ) {\n\t\t\t\tthrow new TypeError( format( 'null2V', arg1 ) );\n\t\t\t}\n\t\t\treturn vectorWithDType( 0, arg0, arg1 );\n\t\t}\n\t\t// Case: vector( arg0, dtype )\n\t\tif ( isDataType( arg1 ) ) {\n\t\t\tout = vectorWithDType( arg0, arg1, null );\n\t\t\tif ( out === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset )\n\t\tif ( isNonNegativeInteger( arg1 ) ) {\n\t\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2B', arg0 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( arg0, options )\n\t\tif ( arg1 === null ) {\n\t\t\tthrow new TypeError( format( 'null2V', arg1 ) );\n\t\t}\n\t\tout = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 );\n\t\tif ( out === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t}\n\t\treturn out;\n\t}\n\targ2 = arguments[ 2 ];\n\n\t// Case: vector( arg0, arg1, arg2 )\n\tif ( nargs === 3 ) {\n\t\t// Case: vector( ArrayBuffer, byteOffset, dtype )\n\t\tif ( isDataType( arg2 ) ) {\n\t\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2B', arg0 ) );\n\t\t\t}\n\t\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2C', arg1 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( arg0, dtype, options )\n\t\tif ( isDataType( arg1 ) ) {\n\t\t\tif ( arg2 === null ) {\n\t\t\t\tthrow new TypeError( format( 'null2V', arg2 ) );\n\t\t\t}\n\t\t\tout = vectorWithDType( arg0, arg1, arg2 );\n\t\t\tif ( out === null ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, arg2 )\n\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', arg0 ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', arg1 ) );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\tif ( isNonNegativeInteger( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, options )\n\t\tif ( arg2 === null ) {\n\t\t\tthrow new TypeError( format( 'null2V', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t}\n\targ3 = arguments[ 3 ];\n\n\t// Case: vector( ArrayBuffer, byteOffset, arg2, arg3 )\n\tif ( nargs === 4 ) {\n\t\tif ( !isArrayBuffer( arg0 ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', arg0 ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', arg1 ) );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length, dtype )\n\t\tif ( isNonNegativeInteger( arg2 ) ) {\n\t\t\tif ( isDataType( arg3 ) ) {\n\t\t\t\treturn arraybuffer2vector( arg3, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, length, options )\n\t\t\tif ( !isPlainObject( arg3 ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2V', arg3 ) );\n\t\t\t}\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, dtype, options )\n\t\tif ( !isDataType( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.', arg2 ) );\n\t\t}\n\t\tif ( !isPlainObject( arg3 ) ) {\n\t\t\tthrow new TypeError( format( 'null2V', arg3 ) );\n\t\t}\n\t\treturn arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 );\n\t}\n\targ4 = arguments[ 4 ];\n\n\t// Case: vector( ArrayBuffer, byteOffset, length, dtype, options )\n\tif ( !isArrayBuffer( arg0 ) ) {\n\t\tthrow new TypeError( format( 'null2B', arg0 ) );\n\t}\n\tif ( !isNonNegativeInteger( arg1 ) ) {\n\t\tthrow new TypeError( format( 'null2C', arg1 ) );\n\t}\n\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\tthrow new TypeError( format( 'null2F', arg2 ) );\n\t}\n\tif ( !isDataType( arg3 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.', arg3 ) );\n\t}\n\tif ( !isPlainObject( arg4 ) ) {\n\t\tthrow new TypeError( format( 'null2V', arg4 ) );\n\t}\n\treturn arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 );\n}\n\n\n// EXPORTS //\n\nexport default vector;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isIterableLike from '@stdlib/assert-is-iterable-like';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isDataType from '@stdlib/ndarray-base-assert-is-data-type';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport validate from './validate.js';\nimport main from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for creating a vector (i.e., a one-dimensional ndarray).\n*\n* @param {string} dtype - data type\n* @param {Options} [options] - function options\n* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector by default\n* @param {string} [options.mode='throw'] - specifies the default behavior when handling indices which exceed vector dimensions\n* @param {string} [options.order='row-major'] - default memory layout (either row-major or column-major)\n* @throws {TypeError} first argument must be a supported data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for creating a vector\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var arr = new Float32Vector( [ 1, 2, 3 ] );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var arr = new Float32Vector( 3 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 3\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf, 4 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n*\n* var Float32Vector = factory( 'float32' );\n*\n* var buf = new ArrayBuffer( 12 );\n* var arr = new Float32Vector( buf, 4, 1 );\n* // returns \n*\n* var dt = getDType( arr );\n* // returns 'float32'\n*\n* var len = numel( arr );\n* // returns 1\n*/\nfunction factory( dtype, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !isDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn vector;\n\n\t/**\n\t* Creates a vector (i.e., a one-dimensional ndarray).\n\t*\n\t* @private\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector\n\t* @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions\n\t* @param {string} [options.order] - memory layout (either row-major or column-major)\n\t* @throws {Error} unexpected error\n\t* @returns {ndarray} one-dimensional ndarray\n\t*/\n\tfunction vector() {\n\t\tvar options;\n\t\tvar nargs;\n\t\tvar arg0;\n\t\tvar arg1;\n\t\tvar err;\n\n\t\toptions = objectAssign( {}, opts );\n\t\tnargs = arguments.length;\n\n\t\t// Case: vector()\n\t\tif ( nargs === 0 ) {\n\t\t\treturn main( dtype, options );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length, options )\n\t\tif ( nargs > 3 ) {\n\t\t\terr = validate( options, arguments[ 3 ] );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, arg2 )\n\t\tif ( nargs === 3 ) {\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\t\tif ( isNonNegativeInteger( arguments[ 2 ] ) ) {\n\t\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, byteOffset, options )\n\t\t\terr = validate( options, arguments[ 2 ] );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arguments[ 0 ], arguments[ 1 ], dtype, options );\n\t\t}\n\t\t// Case: vector( arg0, arg1 )\n\t\tif ( nargs === 2 ) {\n\t\t\targ0 = arguments[ 0 ];\n\t\t\targ1 = arguments[ 1 ];\n\n\t\t\t// Case: vector( length, options )\n\t\t\tif ( isNonNegativeInteger( arg0 ) ) {\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( ArrayBuffer, arg1 )\n\t\t\tif ( isArrayBuffer( arg0 ) ) {\n\t\t\t\t// Case: vector( ArrayBuffer, byteOffset )\n\t\t\t\tif ( isNonNegativeInteger( arg1 ) ) {\n\t\t\t\t\treturn main( arg0, arg1, dtype, options );\n\t\t\t\t}\n\t\t\t\t// Case: vector( ArrayBuffer, options )\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( collection, options )\n\t\t\tif ( isCollection( arg0 ) ) {\n\t\t\t\terr = validate( options, arg1 );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t\treturn main( arg0, dtype, options );\n\t\t\t}\n\t\t\t// Case: vector( iterable, options )\n\t\t\terr = validate( options, arg1 );\n\t\t\tif ( err ) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\treturn main( arg0, dtype, options );\n\t\t}\n\t\t// nargs === 1\n\t\targ0 = arguments[ 0 ];\n\n\t\t// Case: vector( length|ArrayBuffer|Collection|Iterable )\n\t\tif (\n\t\t\tisNonNegativeInteger( arg0 ) ||\n\t\t\tisArrayBuffer( arg0 ) ||\n\t\t\tisCollection( arg0 ) ||\n\t\t\tisIterableLike( arg0 )\n\t\t) {\n\t\t\treturn main( arg0, dtype, options );\n\t\t}\n\t\t// Case: vector( options )\n\t\terr = validate( options, arg0 );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\treturn main( dtype, options );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a vector (i.e., a one-dimensional ndarray).\n*\n* @module @stdlib/ndarray-vector-ctor\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = vector();\n* // returns \n*\n* var len = numel( v );\n* // returns 0\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = vector( 2 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vector( buf );\n* // returns \n*\n* var len = numel( v );\n* // returns 4\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = vector( buf, 16 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import getDType from '@stdlib/ndarray-dtype';\n* import numel from '@stdlib/ndarray-numel';\n* import vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = vector( buf, 16, 2 );\n* // returns \n*\n* var len = numel( v );\n* // returns 2\n*\n* var dt = getDType( v );\n* // returns 'float64'\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport factory from './factory.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"factory\": \"main.factory\" }\n"],"names":["validate","opts","options","isObject","hasOwnProp","readonly","isBoolean","TypeError","format","mode","isIndexMode","order","isOrder","DEFAULT_DTYPE","defaults","get","DEFAULT_ORDER","resolveOrder","arraybuffer2vector","dtype","buffer","length","stride","byteOffset","buf","sh","st","N","o","isGenericDataType","bytesPerElement","isBinaryDataType","arraybuffer2buffer","typedarray","strides2offset","arguments","ndarray","vectorWithDType","arg","isNonNegativeInteger","isBuffer","copy","copyBuffer","isCollection","array2buffer","isArrayBuffer","byteLength","isIterableLike","ITERATOR_SYMBOL","iterator2array","isPlainObject","vector","nargs","arg0","arg1","arg2","arg3","arg4","out","isDataType","factory","err","objectAssign","main","setReadOnly"],"mappings":"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"} \ No newline at end of file diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 29796e2..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isIterableLike = require( '@stdlib/assert-is-iterable-like' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isDataType = require( '@stdlib/ndarray-base-assert-is-data-type' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); -var validate = require( './validate.js' ); -var main = require( './main.js' ); - - -// MAIN // - -/** -* Returns a function for creating a vector (i.e., a one-dimensional ndarray). -* -* @param {string} dtype - data type -* @param {Options} [options] - function options -* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector by default -* @param {string} [options.mode='throw'] - specifies the default behavior when handling indices which exceed vector dimensions -* @param {string} [options.order='row-major'] - default memory layout (either row-major or column-major) -* @throws {TypeError} first argument must be a supported data type -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {Function} function for creating a vector -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = factory( 'float32' ); -* -* var arr = new Float32Vector( 3 ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = factory( 'float32' ); -* -* var buf = new ArrayBuffer( 12 ); -* var arr = new Float32Vector( buf ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = factory( 'float32' ); -* -* var buf = new ArrayBuffer( 12 ); -* var arr = new Float32Vector( buf, 4 ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = factory( 'float32' ); -* -* var buf = new ArrayBuffer( 12 ); -* var arr = new Float32Vector( buf, 4, 1 ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 1 -*/ -function factory( dtype, options ) { - var opts; - var err; - if ( !isDataType( dtype ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) ); - } - opts = {}; - if ( arguments.length > 1 ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - return vector; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @private - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @param {Options} [options] - function options - * @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector - * @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions - * @param {string} [options.order] - memory layout (either row-major or column-major) - * @throws {Error} unexpected error - * @returns {ndarray} one-dimensional ndarray - */ - function vector() { - var options; - var nargs; - var arg0; - var arg1; - var err; - - options = objectAssign( {}, opts ); - nargs = arguments.length; - - // Case: vector() - if ( nargs === 0 ) { - return main( dtype, options ); - } - // Case: vector( ArrayBuffer, byteOffset, length, options ) - if ( nargs > 3 ) { - err = validate( options, arguments[ 3 ] ); - if ( err ) { - throw err; - } - return main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options ); - } - // Case: vector( ArrayBuffer, byteOffset, arg2 ) - if ( nargs === 3 ) { - // Case: vector( ArrayBuffer, byteOffset, length ) - if ( isNonNegativeInteger( arguments[ 2 ] ) ) { - return main( arguments[ 0 ], arguments[ 1 ], arguments[ 2 ], dtype, options ); - } - // Case: vector( ArrayBuffer, byteOffset, options ) - err = validate( options, arguments[ 2 ] ); - if ( err ) { - throw err; - } - return main( arguments[ 0 ], arguments[ 1 ], dtype, options ); - } - // Case: vector( arg0, arg1 ) - if ( nargs === 2 ) { - arg0 = arguments[ 0 ]; - arg1 = arguments[ 1 ]; - - // Case: vector( length, options ) - if ( isNonNegativeInteger( arg0 ) ) { - err = validate( options, arg1 ); - if ( err ) { - throw err; - } - return main( arg0, dtype, options ); - } - // Case: vector( ArrayBuffer, arg1 ) - if ( isArrayBuffer( arg0 ) ) { - // Case: vector( ArrayBuffer, byteOffset ) - if ( isNonNegativeInteger( arg1 ) ) { - return main( arg0, arg1, dtype, options ); - } - // Case: vector( ArrayBuffer, options ) - err = validate( options, arg1 ); - if ( err ) { - throw err; - } - return main( arg0, dtype, options ); - } - // Case: vector( collection, options ) - if ( isCollection( arg0 ) ) { - err = validate( options, arg1 ); - if ( err ) { - throw err; - } - return main( arg0, dtype, options ); - } - // Case: vector( iterable, options ) - err = validate( options, arg1 ); - if ( err ) { - throw err; - } - return main( arg0, dtype, options ); - } - // nargs === 1 - arg0 = arguments[ 0 ]; - - // Case: vector( length|ArrayBuffer|Collection|Iterable ) - if ( - isNonNegativeInteger( arg0 ) || - isArrayBuffer( arg0 ) || - isCollection( arg0 ) || - isIterableLike( arg0 ) - ) { - return main( arg0, dtype, options ); - } - // Case: vector( options ) - err = validate( options, arg0 ); - if ( err ) { - throw err; - } - return main( dtype, options ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59ffda5..0000000 --- a/lib/index.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a vector (i.e., a one-dimensional ndarray). -* -* @module @stdlib/ndarray-vector-ctor -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = vector(); -* // returns -* -* var len = numel( v ); -* // returns 0 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = vector( 2 ); -* // returns -* -* var len = numel( v ); -* // returns 2 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = numel( v ); -* // returns 2 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = numel( v ); -* // returns 2 -* -* var dt = getDType( v ); -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = vector( buf ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = vector( buf, 16 ); -* // returns -* -* var len = numel( v ); -* // returns 2 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = vector( buf, 16, 2 ); -* // returns -* -* var len = numel( v ); -* // returns 2 -* -* var dt = getDType( v ); -* // returns 'float64' -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var factory = require( './factory.js' ); -var main = require( './main.js' ); - - -// MAIN // - -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "factory": "main.factory" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 1f88cd8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,590 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isIterableLike = require( '@stdlib/assert-is-iterable-like' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isGenericDataType = require( '@stdlib/ndarray-base-assert-is-generic-data-type' ); -var isBinaryDataType = require( '@stdlib/ndarray-base-assert-is-binary-data-type' ); -var isDataType = require( '@stdlib/ndarray-base-assert-is-data-type' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var buffer = require( '@stdlib/ndarray-base-buffer' ); -var typedarray = require( '@stdlib/array-typed' ); -var copy = require( '@stdlib/array-base-copy' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var defaults = require( '@stdlib/ndarray-defaults' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var arraybuffer2buffer = require( '@stdlib/buffer-from-arraybuffer' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var copyBuffer = require( '@stdlib/buffer-from-buffer' ); -var iterator2array = require( '@stdlib/array-from-iterator' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Resolves the order of the output vector. -* -* @private -* @param {*} options - options argument -* @returns {string} order -*/ -function resolveOrder( options ) { - if ( hasOwnProp( options, 'order' ) ) { - return options.order; - } - return DEFAULT_ORDER; -} - -/** -* Creates a one-dimensional ndarray from an ArrayBuffer. -* -* @private -* @param {string} dtype - data type -* @param {ArrayBuffer} buffer - ArrayBuffer -* @param {NonNegativeInteger} length - number of indexed elements -* @param {integer} stride - stride length (in units of elements) -* @param {NonNegativeInteger} byteOffset - byte offset of the first indexed element -* @param {string} order - memory layout (either row-major or column-major) -* @param {Options} [options] - function options -* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray -* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions -* @throws {TypeError} data type must be compatible with the provided ArrayBuffer -* @returns {ndarray} one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 4, 1, 0, 'row-major' ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float32', buf, 8, 1, 0, 'row-major' ); -* // returns -* -* var len = numel( v ); -* // returns 8 -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 4, -1, 32, 'row-major' ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 2, -1, 24, 'row-major' ); -* // returns -* -* var len = numel( v ); -* // returns 2 -*/ -function arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) { // TODO: replace with `@stdlib/ndarray/from-arraybuffer` - var buf; - var sh; - var st; - var N; - var o; - - if ( isGenericDataType( dtype ) ) { - throw new TypeError( format( 'invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.', dtype ) ); - } - o = byteOffset; - - // Compute the number of underlying elements across which the vector view will span: - N = length * stride; - - // Adjust the byte offset to point to the element marking the beginning of the view: - if ( stride < 0 ) { // TODO: the following is effectively unreachable code, as provided strides are never anything other than unity; however, we keep this around in the event that we want to extract this function to a separate package and would like to maintain generality - N *= -1; - o -= N * bytesPerElement( dtype ); // FIXME: this is incorrect for the general case - } - // Create the underlying ndarray buffer: - if ( isBinaryDataType( dtype ) ) { - buf = arraybuffer2buffer( buffer, o, N ); - } else { - buf = typedarray( buffer, o, N, dtype ); - } - // Resolve ndarray meta data: - sh = [ length ]; - st = [ stride ]; - o = strides2offset( sh, st ); - - // Return a new ndarray instance: - if ( arguments.length > 6 ) { - return new ndarray( dtype, buf, sh, st, o, order, options ); - } - return new ndarray( dtype, buf, sh, st, o, order ); -} - -/** -* Returns a vector having a specified data type. -* -* @private -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Buffer|Iterable|Options)} arg - length, typed array, array-like object, buffer, iterable, or options object -* @param {string} dtype - data type -* @param {(Options|null)} options - function options -* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only ndarray -* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed ndarray dimensions -* @returns {(ndarray|null)} one-dimensional ndarray -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var v = vectorWithDType( 10, 'float64', {} ); -* // returns -* -* var len = numel( v ); -* // returns 10 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* var dt = getDType( v ); -* // returns 'generic' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = vectorWithDType( buf, 'float64', {} ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var v = vectorWithDType( {}, 'float64', null ); -* // returns -* -* var len = numel( v ); -* // returns 0 -* -* var dt = getDType( v ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var array2iterator = require( '@stdlib/array-to-iterator' ); -* -* var v = vectorWithDType( array2iterator( [ 1, 2, 3, 4 ] ), 'generic', {} ); -* // returns -* -* var len = numel( v ); -* // returns 4 -* -* var dt = getDType( v ); -* // returns 'generic' -*/ -function vectorWithDType( arg, dtype, options ) { - var opts; - var buf; - - // Note: in all of the following, we delegate option validation to the ndarray constructor... - if ( options === null ) { - opts = {}; - } else { - opts = options; - } - // Case: vector( length ) - if ( isNonNegativeInteger( arg ) ) { - buf = buffer( dtype, arg ); - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: vector( Buffer ) - if ( isBuffer( arg ) ) { - if ( isGenericDataType( dtype ) ) { - buf = copy( arg ); - } else if ( isBinaryDataType( dtype ) ) { - buf = copyBuffer( arg ); - } else { - buf = typedarray( arg, dtype ); - } - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: vector( collection ) - if ( isCollection( arg ) ) { - if ( isGenericDataType( dtype ) ) { - buf = copy( arg ); - } else if ( isBinaryDataType( dtype ) ) { - buf = array2buffer( arg ); // note: we assume that `arg` is an array of octets - } else { - buf = typedarray( arg, dtype ); - } - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: vector( ArrayBuffer ) - if ( isArrayBuffer( arg ) ) { - return arraybuffer2vector( dtype, arg, arg.byteLength/bytesPerElement( dtype ), 1, 0, resolveOrder( opts ), opts ); - } - // Case: vector( Iterable ) - if ( isIterableLike( arg ) ) { - buf = arg[ ITERATOR_SYMBOL ](); - buf = iterator2array( buf ); - if ( isBinaryDataType( dtype ) ) { - buf = array2buffer( buf ); - } else if ( !isGenericDataType( dtype ) ) { - buf = typedarray( buf, dtype ); - } - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: vector( options ) - if ( options === null && isPlainObject( arg ) ) { - buf = buffer( dtype, 0 ); - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( arg ), arg ); - } - return null; -} - - -// MAIN // - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* ## Notes -* -* - This API is intended to match the conventions of `@stdlib/array/typed`, which has a similar signature. -* -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype='float64'] - data type -* @param {Options} [options] - function options -* @param {boolean} [options.readonly=false] - boolean indicating whether to return a read-only vector -* @param {string} [options.mode='throw'] - specifies how to handle indices which exceed vector dimensions -* @param {string} [options.order='row-major'] - memory layout (either row-major or column-major) -* @throws {TypeError} first argument must be either a length, typed array, array-like object, buffer, iterable, data type, or options object -* @throws {TypeError} must provide valid options -* @returns {ndarray} one-dimensional ndarray -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var arr = vector(); -* // returns -* -* var len = numel( arr ); -* // returns 0 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var arr = vector( 2 ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var arr = vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var arr = vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf ); -* // returns -* -* var len = numel( arr ); -* // returns 4 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 16 ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = vector( buf, 16, 2 ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -function vector() { - var nargs; - var arg0; - var arg1; - var arg2; - var arg3; - var arg4; - var buf; - var out; - - nargs = arguments.length; - - // Case: vector() - if ( nargs === 0 ) { - buf = buffer( DEFAULT_DTYPE, 0 ); - return new ndarray( DEFAULT_DTYPE, buf, [ buf.length ], [ 1 ], 0, DEFAULT_ORDER ); - } - arg0 = arguments[ 0 ]; - - // Case: vector( arg0 ); - if ( nargs === 1 ) { - if ( isDataType( arg0 ) ) { - return vectorWithDType( 0, arg0, null ); - } - out = vectorWithDType( arg0, DEFAULT_DTYPE, null ); - if ( out === null ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.', arg0 ) ); - } - return out; - } - arg1 = arguments[ 1 ]; - - // Case: vector( arg0, arg1 ) - if ( nargs === 2 ) { - // Case: vector( dtype, options ) - if ( isDataType( arg0 ) ) { - if ( arg1 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg1 ) ); - } - return vectorWithDType( 0, arg0, arg1 ); - } - // Case: vector( arg0, dtype ) - if ( isDataType( arg1 ) ) { - out = vectorWithDType( arg0, arg1, null ); - if ( out === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) ); - } - return out; - } - // Case: vector( ArrayBuffer, byteOffset ) - if ( isNonNegativeInteger( arg1 ) ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( arg0, options ) - if ( arg1 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg1 ) ); - } - out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); - if ( out === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) ); - } - return out; - } - arg2 = arguments[ 2 ]; - - // Case: vector( arg0, arg1, arg2 ) - if ( nargs === 3 ) { - // Case: vector( ArrayBuffer, byteOffset, dtype ) - if ( isDataType( arg2 ) ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); - } - return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( arg0, dtype, options ) - if ( isDataType( arg1 ) ) { - if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); - } - out = vectorWithDType( arg0, arg1, arg2 ); - if ( out === null ) { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.', arg0 ) ); - } - return out; - } - // Case: vector( ArrayBuffer, byteOffset, arg2 ) - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); - } - // Case: vector( ArrayBuffer, byteOffset, length ) - if ( isNonNegativeInteger( arg2 ) ) { - return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( ArrayBuffer, byteOffset, options ) - if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); - } - arg3 = arguments[ 3 ]; - - // Case: vector( ArrayBuffer, byteOffset, arg2, arg3 ) - if ( nargs === 4 ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); - } - // Case: vector( ArrayBuffer, byteOffset, length, dtype ) - if ( isNonNegativeInteger( arg2 ) ) { - if ( isDataType( arg3 ) ) { - return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( ArrayBuffer, byteOffset, length, options ) - if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); - } - // Case: vector( ArrayBuffer, byteOffset, dtype, options ) - if ( !isDataType( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.', arg2 ) ); - } - if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); - } - return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); - } - arg4 = arguments[ 4 ]; - - // Case: vector( ArrayBuffer, byteOffset, length, dtype, options ) - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); - } - if ( !isDataType( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.', arg3 ) ); - } - if ( !isPlainObject( arg4 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg4 ) ); - } - return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); -} - - -// EXPORTS // - -module.exports = vector; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc0185e..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert-is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isIndexMode = require( '@stdlib/ndarray-base-assert-is-index-mode' ); -var isOrder = require( '@stdlib/ndarray-base-assert-is-order' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {boolean} [options.readonly] - boolean indicating whether to return a read-only vector -* @param {string} [options.mode] - specifies how to handle indices which exceed vector dimensions -* @param {string} [options.order] - memory layout (either row-major or column-major) -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'readonly': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readonly', opts.readonly ) ); - } - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - if ( !isIndexMode( opts.mode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a valid index mode. Option: `%s`.', 'mode', opts.mode ) ); - } - } - if ( hasOwnProp( options, 'order' ) ) { - opts.order = options.order; - if ( !isOrder( opts.order ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a memory layout. Option: `%s`.', 'order', opts.order ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index abb61a9..806c33a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a vector (i.e., a one-dimensional ndarray).", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,82 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-from-iterator": "^0.2.3", - "@stdlib/array-typed": "^0.3.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-iterable-like": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/buffer-from-arraybuffer": "^0.2.3", - "@stdlib/buffer-from-buffer": "^0.2.3", - "@stdlib/ndarray-base-assert-is-binary-data-type": "github:stdlib-js/ndarray-base-assert-is-binary-data-type#main", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.3", - "@stdlib/ndarray-base-assert-is-generic-data-type": "github:stdlib-js/ndarray-base-assert-is-generic-data-type#main", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.3", - "@stdlib/ndarray-base-assert-is-order": "^0.2.3", - "@stdlib/ndarray-base-buffer": "^0.3.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-defaults": "^0.4.1", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/string-format": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/array-cartesian-product": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-to-iterator": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-method": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-ndarray-like-with-data-type": "^0.1.1", - "@stdlib/assert-is-same-array": "^0.2.3", - "@stdlib/assert-is-same-complex128array": "^0.2.3", - "@stdlib/assert-is-same-float32array": "^0.2.3", - "@stdlib/assert-is-same-float64array": "^0.2.3", - "@stdlib/blas-ext-sum": "^0.1.1", - "@stdlib/console-log-each-map": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-data-buffer": "^0.2.3", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/utils-unzip": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..17cc065 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index f7eb044..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,1515 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLikeWithDataType = require( '@stdlib/assert-is-ndarray-like-with-data-type' ); -var isSameFloat32Array = require( '@stdlib/assert-is-same-float32array' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var factory = require( './../lib' ).factory; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'float32', value ); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'float32', { - 'readonly': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a supported mode', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'float32', { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a supported order', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( 'float32', { - 'order': value - }); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument (options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument (byteoffset)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid byte offset argument', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid byte offset argument (options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid byte offset argument (length)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1 ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid length argument', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid length argument (options)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value, {} ); - }; - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ) ); - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer, options)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ), {} ); - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer, byteoffset)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ), 0 ); - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer, byteoffset, options)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ), 0, {} ); - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer, byteoffset, length)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ), 0, 2 ); - } -}); - -tape( 'the function returns a function which throws an error if parameterized to return an ndarray having a "generic" data type (arraybuffer, byteoffset, length, options)', function test( t ) { - var vector = factory( 'generic' ); - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - vector( new ArrayBuffer( 16 ), 0, 2, {} ); - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object (length)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( 10, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object (array)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( [], value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - null - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'order': value - }); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'mode': value - }); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var vector; - var values; - var i; - - vector = factory( 'float32' ); - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - arr = vector( {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( 10 ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - arr = vector( 10, {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (array)', function test( t ) { - var vector; - var arr; - var out; - - vector = factory( 'float32' ); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - - out = vector( arr ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - out = vector( arr, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (typed array)', function test( t ) { - var vector; - var arr; - var out; - - vector = factory( 'float32' ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - out = vector( arr ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - out = vector( arr, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (buffer)', function test( t ) { - var vector; - var arr; - var out; - var buf; - - vector = factory( 'float32' ); - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - - out = vector( buf ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - out = vector( buf, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (arraybuffer)', function test( t ) { - var vector; - var buf; - var out; - - vector = factory( 'float32' ); - - buf = new ArrayBuffer( 8 ); - - out = vector( buf ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf ) ), true, 'returns expected value' ); - - out = vector( buf, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (arraybuffer, byteoffset)', function test( t ) { - var vector; - var buf; - var out; - - vector = factory( 'float32' ); - - buf = new ArrayBuffer( 32 ); - - out = vector( buf, 8 ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8 ) ), true, 'returns expected value' ); - - out = vector( buf, 8, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8 ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which returns a one-dimensional ndarray (arraybuffer, byteoffset, length)', function test( t ) { - var vector; - var buf; - var out; - - vector = factory( 'float32' ); - - buf = new ArrayBuffer( 32 ); - - out = vector( buf, 8, 2 ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8, 2 ) ), true, 'returns expected value' ); - - out = vector( buf, 8, 2, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8, 2 ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the default memory layout (row-major)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32', { - 'order': 'row-major' - }); - - arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector({ - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector({ - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the default memory layout (column-major)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32', { - 'order': 'column-major' - }); - - arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - arr = vector({ - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector({ - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector({ - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector({ - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout (length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( 10, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( 10, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout (array)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout (arraybuffer)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying whether to return read-only ndarrays by default', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32', { - 'readonly': true - }); - - arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - arr = vector({ - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - arr = vector({ - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector({ - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays (length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( 10, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays (array)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays (arraybuffer)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying whether to return writable ndarrays by default', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32', { - 'readonly': false - }); - - arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - arr = vector({ - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - arr = vector({ - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector({ - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays (length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( 10, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays (array)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays (arraybuffer)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function which supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { - var vector; - var arr; - - vector = factory( 'float32' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index cada754..0000000 --- a/test/test.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isMethod = require( '@stdlib/assert-is-method' ); -var vector = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof vector, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `factory` method', function test( t ) { - t.strictEqual( isMethod( vector, 'factory' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 2708904..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,3173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var isndarrayLikeWithDataType = require( '@stdlib/assert-is-ndarray-like-with-data-type' ); -var isSameFloat64Array = require( '@stdlib/assert-is-same-float64array' ); -var isSameFloat32Array = require( '@stdlib/assert-is-same-float32array' ); -var isSameComplex128Array = require( '@stdlib/assert-is-same-complex128array' ); -var isSameArray = require( '@stdlib/assert-is-same-array' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var arraybuffer2buffer = require( '@stdlib/buffer-from-arraybuffer' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var vector = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof vector, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid first argument (byteoffset, length, dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, 0, 1, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (length, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (length, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid byte offset argument (length, dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value, 1, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid length argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid length argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value, 'float64' ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid length argument (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid length argument (dtype, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value, 'float64', {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer, byteoffset, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (arraybuffer, byteoffset, length, options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer, options)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer, byteoffset, options)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a "generic" data type (arraybuffer, byteoffset, length, options)', function test( t ) { - var values; - var i; - - values = [ - 'generic' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 16 ), 0, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [ '5' ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( 'float64', value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( [], value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (array, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( [], 'float64', value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 'float64', value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, 'float64', value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (arraybuffer, byteoffset, length, dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector( new ArrayBuffer( 8 ), 0, 1, 'float64', value ); - }; - } -}); - -tape( 'the function throws an error if provided an `order` option which is not a recognized order', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ROW', - 'row', - 'col-major', - 'col', - 'major', - 'minor', - null - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'order': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a recognized mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'THROW', - 5, - null, - true, - false, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - vector({ - 'readonly': value - }); - }; - } -}); - -tape( 'the function returns a one-dimensional ndarray (default)', function test( t ) { - var arr = vector(); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, options)', function test( t ) { - var arr = vector( {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64)', function test( t ) { - var arr = vector( 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, options)', function test( t ) { - var arr = vector( 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32)', function test( t ) { - var arr = vector( 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, options)', function test( t ) { - var arr = vector( 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128)', function test( t ) { - var arr = vector( 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary)', function test( t ) { - var arr = vector( 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'binary' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic)', function test( t ) { - var arr = vector( 'generic' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'generic' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, length)', function test( t ) { - var arr = vector( 10 ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, length, options)', function test( t ) { - var arr = vector( 10, {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, length)', function test( t ) { - var arr = vector( 10, 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, length, options)', function test( t ) { - var arr = vector( 10, 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, length)', function test( t ) { - var arr = vector( 10, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, length, options)', function test( t ) { - var arr = vector( 10, 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, length)', function test( t ) { - var arr = vector( 10, 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, length)', function test( t ) { - var arr = vector( 10, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'binary' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, length)', function test( t ) { - var arr = vector( 10, 'generic' ); - t.strictEqual( isndarrayLikeWithDataType( arr, 'generic' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, array)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, array, options)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, array)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, array, options)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, array)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, array, options)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'complex128', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, 3, 4 ]; - out = vector( arr, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, array, options)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, 3, 4 ]; - out = vector( arr, 'binary', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, array)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'generic' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, array, options)', function test( t ) { - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( arr, 'generic', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, typed array, options)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, typed array, options)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, typed array, options)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = vector( arr, 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, complex typed array)', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = vector( arr, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, iterable)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ) ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (default, iterable, options)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, iterable)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, iterable, options)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, iterable)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, iterable, options)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'complex128', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, iterable)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1, 2, 3, 4 ]; - out = vector( createIterable( arr ), 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, iterable, options)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1, 2, 3, 4 ]; - out = vector( createIterable( arr ), 'binary', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, iterable)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'generic' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, iterable, options)', function test( t ) { - var vector; - var arr; - var out; - - vector = proxyquire( './../lib/main.js', { - '@stdlib/assert-is-iterable-like': mock, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = vector( createIterable( arr ), 'generic', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); - - function createIterable( arr ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return array2iterator( arr ); - } - } - - function mock() { - return true; - } -}); - -tape( 'the function returns a one-dimensional ndarray (default, buffer)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, buffer, options)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, buffer)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, buffer, options)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, buffer)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, buffer, options)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'complex128', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( arr ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, buffer)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, buffer, options)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'binary', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.deepEqual( getData( out ), array2buffer( arr ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, buffer)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'generic' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=generic, buffer, options)', function test( t ) { - var arr; - var out; - var buf; - - arr = [ 1, 2, 3, 4 ]; - buf = array2buffer( arr ); - out = vector( buf, 'generic', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'generic' ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( isSameArray( getData( out ), arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer, options)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 'float64' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float64, arraybuffer, options)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 'float64', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer, options)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=complex128, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = vector( buf, 'complex128' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'complex128' ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( getData( out ), new Complex128Array( buf ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.deepEqual( getData( out ), arraybuffer2buffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8 ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf, 8 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer, byteoffset, options)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf, 8 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 2, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.deepEqual( getData( out ), arraybuffer2buffer( buf, 2 ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer, byteoffset, options)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 2 ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf, 8, 2 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (default, arraybuffer, byteoffset, length, options)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 2, {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float64' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( getData( out ), new Float64Array( buf, 8, 2 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 2, 'float32' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8, 2 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=float32, arraybuffer, byteoffset, length, options)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = vector( buf, 8, 2, 'float32', {} ); - t.strictEqual( isndarrayLikeWithDataType( out, 'float32' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( isSameFloat32Array( getData( out ), new Float32Array( buf, 8, 2 ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a one-dimensional ndarray (dtype=binary, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = vector( buf, 2, 2, 'binary' ); - t.strictEqual( isndarrayLikeWithDataType( out, 'binary' ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.deepEqual( getData( out ), arraybuffer2buffer( buf, 2, 2 ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports specifying the memory layout', function test( t ) { - var arr; - - arr = vector({ - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector({ - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (dtype)', function test( t ) { - var arr; - - arr = vector( 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (length)', function test( t ) { - var arr; - - arr = vector( 10, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( 10, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (length, dtype)', function test( t ) { - var arr; - - arr = vector( 10, 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( 10, 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (array)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (array, dtype)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying the memory layout (arraybuffer, byteoffset, length, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, 'float32', { - 'order': 'row-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'row-major', 'returns expected value' ); - - arr = vector( new ArrayBuffer( 32 ), 8, 2, 'float32', { - 'order': 'column-major' - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( arr.order, 'column-major', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays', function test( t ) { - var arr; - - arr = vector({ - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (dtype)', function test( t ) { - var arr; - - arr = vector( 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (length)', function test( t ) { - var arr; - - arr = vector( 10, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (length, dtype)', function test( t ) { - var arr; - - arr = vector( 10, 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (array)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (array, dtype)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning read-only ndarrays (arraybuffer, byteoffset, length, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, 'float32', { - 'readonly': true - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays', function test( t ) { - var arr; - - arr = vector({ - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (dtype)', function test( t ) { - var arr; - - arr = vector( 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (length)', function test( t ) { - var arr; - - arr = vector( 10, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (length, dtype)', function test( t ) { - var arr; - - arr = vector( 10, 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (array)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (array, dtype)', function test( t ) { - var arr; - - arr = vector( [ 1.0, 2.0, 3.0, 4.0 ], 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 4, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 8, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 6, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float64' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports returning writable ndarrays (arraybuffer, byteoffset, length, dtype)', function test( t ) { - var arr; - - arr = vector( new ArrayBuffer( 32 ), 8, 2, 'float32', { - 'readonly': false - }); - t.strictEqual( isndarrayLikeWithDataType( arr, 'float32' ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - t.strictEqual( isReadOnly( arr ), false, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index d165b91..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `readonly` option which is not a boolean', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readonly': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `order` option which is not a valid order', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'order': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `mode` option which is not a valid mode', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'mode': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'readonly': true, - 'order': 'row-major', - 'mode': 'throw' - }; - opts = {}; - - expected = { - 'readonly': true, - 'order': 'row-major', - 'mode': 'throw' - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -});