From 0265dd01c38a355abe289d472873efdb960b1c3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 03:06:52 +0000 Subject: [PATCH 01/69] Transform error messages --- lib/main.js | 30 +++++++++++++++--------------- package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7f36f24..ce26213 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ 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 format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -454,7 +454,7 @@ function Vector() { // Case: new Vector( ArrayBuffer, byteOffset ) if ( isNonNegativeInteger( arg1 ) ) { if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER ); } @@ -472,10 +472,10 @@ function Vector() { // Case: new 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER ); } @@ -489,10 +489,10 @@ function Vector() { } // Case: new Vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: new Vector( ArrayBuffer, byteOffset, options ) if ( isPlainObject( arg2 ) ) { @@ -500,7 +500,7 @@ function Vector() { } // Case: new Vector( ArrayBuffer, byteOffset, length ) if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER ); } @@ -509,10 +509,10 @@ function Vector() { // Case: new 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: new Vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -521,7 +521,7 @@ function Vector() { } // Case: new Vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -530,7 +530,7 @@ function Vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -538,19 +538,19 @@ function Vector() { // Case: new Vector( ArrayBuffer, byteOffset, length, dtype, options ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/package.json b/package.json index 2695d38..6818f20 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@stdlib/ndarray-base-strides2offset": "^0.2.2", "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 93ac23ae4c0f23e905d2de3a6dc9ee3e4d456f9f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 May 2025 03:08:09 +0000 Subject: [PATCH 02/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 48 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 71 +- SECURITY.md | 5 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 202 - docs/types/test.ts | 83 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 124 - lib/main.js | 561 -- package.json | 80 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 44 files changed, 4881 insertions(+), 4996 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -301,7 +292,7 @@ logEachMap( 'len: %2d. dtype: %10s. shape: [%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]. @@ -364,11 +355,11 @@ Copyright © 2016-2025. 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
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.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 42b73cb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var N=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var P=N(function(Y,k){"use strict";var l=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,x=require("@stdlib/assert-is-iterable-like"),z=require("@stdlib/assert-is-collection"),b=require("@stdlib/assert-is-arraybuffer"),E=require("@stdlib/assert-is-plain-object"),I=require("@stdlib/assert-is-buffer"),g=require("@stdlib/ndarray-base-assert-is-data-type"),R=require("@stdlib/assert-has-own-property"),F=require("@stdlib/ndarray-base-buffer"),d=require("@stdlib/array-typed"),L=require("@stdlib/array-base-copy"),m=require("@stdlib/ndarray-ctor"),O=require("@stdlib/ndarray-defaults"),U=require("@stdlib/ndarray-base-strides2offset"),_=require("@stdlib/buffer-from-arraybuffer"),j=require("@stdlib/buffer-from-array"),C=require("@stdlib/buffer-from-buffer"),D=require("@stdlib/array-from-iterator"),c=require("@stdlib/ndarray-base-bytes-per-element"),i=require("@stdlib/string-format"),f=O.get("dtypes.default"),h=O.get("order");function B(e){return e==="generic"}function A(e){return e==="binary"}function s(e){return R(e,"order")?e.order:h}function o(e,r,a,n,t,v,T){var u,V,q,p,w;if(B(e))throw new TypeError(i("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return w=t,p=a*n,n<0&&(p*=-1,w-=p*c(e)),A(e)?u=_(r,w,p):u=d(r,w,p,e),V=[a],q=[n],w=U(V,q),arguments.length>6?new m(e,u,V,q,w,v,T):new m(e,u,V,q,w,v)}function y(e,r,a){var n,t;return a===null?n={}:n=a,l(e)?(t=F(r,e),new m(r,t,[t.length],[1],0,s(n),n)):I(e)?(B(r)?t=L(e):A(r)?t=C(e):t=d(e,r),new m(r,t,[t.length],[1],0,s(n),n)):z(e)?(B(r)?t=L(e):A(r)?t=j(e):t=d(e,r),new m(r,t,[t.length],[1],0,s(n),n)):b(e)?o(r,e,e.byteLength/c(r),1,0,s(n),n):x(e)?(B(r)?t=D(e):A(r)?t=j(D(e)):t=d(e,r),new m(r,t,[t.length],[1],0,s(n),n)):a===null&&E(e)?(t=F(r,0),new m(r,t,[t.length],[1],0,s(e),e)):null}function G(){var e,r,a,n,t,v,T,u;if(e=arguments.length,e===0)return T=F(f,0),new m(f,T,[T.length],[1],0,h);if(r=arguments[0],e===1){if(g(r))return y(0,r,null);if(u=y(r,f,null),u===null)throw new TypeError(i("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return u}if(a=arguments[1],e===2){if(g(r))return y(0,r,a);if(g(a)){if(u=y(r,a,null),u===null)throw new TypeError(i("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return u}if(l(a)){if(!b(r))throw new TypeError(i("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return o(f,r,(r.byteLength-a)/c(f),1,a,h)}if(u=y(r,f,a),u===null)throw new TypeError(i("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return u}if(n=arguments[2],e===3){if(g(n)){if(!b(r))throw new TypeError(i("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!l(a))throw new TypeError(i("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));return o(n,r,(r.byteLength-a)/c(n),1,a,h)}if(g(a)){if(u=y(r,a,n),u===null)throw new TypeError(i("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return u}if(!b(r))throw new TypeError(i("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!l(a))throw new TypeError(i("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(E(n))return o(f,r,(r.byteLength-a)/c(f),1,a,s(n),n);if(!l(n))throw new TypeError(i("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));return o(f,r,n,1,a,h)}if(t=arguments[3],e===4){if(!b(r))throw new TypeError(i("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!l(a))throw new TypeError(i("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(l(n)){if(g(t))return o(t,r,n,1,a,h);if(!E(t))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t));return o(f,r,n,1,a,s(t),t)}if(!g(n))throw new TypeError(i("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",n));if(!E(t))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t));return o(n,r,(r.byteLength-a)/c(n),1,a,s(t),t)}if(v=arguments[4],!b(r))throw new TypeError(i("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!l(a))throw new TypeError(i("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",a));if(!l(n))throw new TypeError(i("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));if(!g(t))throw new TypeError(i("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",t));if(!E(v))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",v));return o(t,r,n,1,a,s(v),v)}k.exports=G});var M=P();module.exports=M; -/** -* @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 1034cf5..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.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/* 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 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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 8\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 2\n*/\nfunction arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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 v = vectorWithDType( 10, 'float64', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 10\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'generic'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( {}, 'float64', null );\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\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: new 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: new 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: new 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: new 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: new Vector( Iterable )\n\tif ( isIterableLike( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = iterator2array( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( iterator2array( arg ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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: new 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* @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 v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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: new 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: new 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: new Vector( arg0, arg1 )\n\tif ( nargs === 2 ) {\n\t\t// Case: new Vector( dtype, options )\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\treturn vectorWithDType( 0, arg0, arg1 );\n\t\t}\n\t\t// Case: new 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: new 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: new Vector( arg0, options )\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: new Vector( arg0, arg1, arg2 )\n\tif ( nargs === 3 ) {\n\t\t// Case: new 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: new Vector( arg0, dtype, options )\n\t\tif ( isDataType( arg1 ) ) {\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: new 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: new Vector( ArrayBuffer, byteOffset, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: new Vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t}\n\targ3 = arguments[ 3 ];\n\n\t// Case: new 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: new 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: new 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: new 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: new 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'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 Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isIterableLike", "isCollection", "isArrayBuffer", "isPlainObject", "isBuffer", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "length", "stride", "byteOffset", "order", "buf", "sh", "st", "N", "o", "vectorWithDType", "arg", "opts", "Vector", "nargs", "arg0", "arg1", "arg2", "arg3", "arg4", "out", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7b632c0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,202 +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 = arr.dtype - 'float64' - > arr = {{alias}}( 'float32' ) - - > dt = arr.dtype - '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 = arr.dtype - 'float64' - > var len = {{alias:@stdlib/ndarray/numel}}( arr ) - 5 - > arr = {{alias}}( 5, 'float32' ) - - > dt = arr.dtype - '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 = arr.dtype - '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}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - - > var dt = arr.dtype - 'float32' - > var len = {{alias:@stdlib/ndarray/numel}}( arr ) - 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6abfec2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +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 array2iterator = require( '@stdlib/array-to-iterator' ); -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( array2iterator( [ 1, 2, 3 ] ) ); // $ExpectType float64ndarray - vector( array2iterator( [ 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( array2iterator( [ 1, 2, 3 ] ), 'int32' ); // $ExpectType int32ndarray - vector( array2iterator( [ 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 objects... -{ - 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 -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a4d3f63..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 getShape = require( '@stdlib/ndarray-shape' ); -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 date types: -var dts = dtypes(); - -// 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 vector and return the vector shape: -function clbk( len, dtype ) { - var x = vector( len, dtype ); - return getShape( x ); -} - -// Apply the callback and print the results: -logEachMap( 'len: %2d. dtype: %10s. shape: [%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 4764f19..0babe14 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/unified-signatures */ -/// +/// import { 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..90815e8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import l 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/assert-has-own-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=u.get("dtypes.default"),c=u.get("order");function T(r){return"generic"===r}function x(r){return"binary"===r}function E(r){return o(r,"order")?r.order:c}function B(r,e,t,n,s,i,l){var o,a,m,u,j;if(T(r))throw new TypeError(v("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return j=s,u=t*n,n<0&&(j-=(u*=-1)*g(r)),o=x(r)?h(e,j,u):d(e,j,u,r),j=p(a=[t],m=[n]),arguments.length>6?new f(r,o,a,m,j,i,l):new f(r,o,a,m,j,i)}function V(l,o,u){var p,h;return p=null===u?{}:u,r(l)?(h=a(o,l),new f(o,h,[h.length],[1],0,E(p),p)):i(l)?(h=T(o)?m(l):x(o)?y(l):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):t(l)?(h=T(o)?m(l):x(o)?j(l):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):n(l)?B(o,l,l.byteLength/g(o),1,0,E(p),p):e(l)?(h=T(o)?b(l):x(o)?j(b(l)):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):null===u&&s(l)?(h=a(o,0),new f(o,h,[h.length],[1],0,E(l),l)):null}function F(){var e,t,i,o,d,m,u,p;if(0===(e=arguments.length))return u=a(w,0),new f(w,u,[u.length],[1],0,c);if(t=arguments[0],1===e){if(l(t))return V(0,t,null);if(null===(p=V(t,w,null)))throw new TypeError(v("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return p}if(i=arguments[1],2===e){if(l(t))return V(0,t,i);if(l(i)){if(null===(p=V(t,i,null)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(r(i)){if(!n(t))throw new TypeError(v("null2B",t));return B(w,t,(t.byteLength-i)/g(w),1,i,c)}if(null===(p=V(t,w,i)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(o=arguments[2],3===e){if(l(o)){if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));return B(o,t,(t.byteLength-i)/g(o),1,i,c)}if(l(i)){if(null===(p=V(t,i,o)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(s(o))return B(w,t,(t.byteLength-i)/g(w),1,i,E(o),o);if(!r(o))throw new TypeError(v("null2F",o));return B(w,t,o,1,i,c)}if(d=arguments[3],4===e){if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(r(o)){if(l(d))return B(d,t,o,1,i,c);if(!s(d))throw new TypeError(v("null2V",d));return B(w,t,o,1,i,E(d),d)}if(!l(o))throw new TypeError(v("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!s(d))throw new TypeError(v("null2V",d));return B(o,t,(t.byteLength-i)/g(o),1,i,E(d),d)}if(m=arguments[4],!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(!r(o))throw new TypeError(v("null2F",o));if(!l(d))throw new TypeError(v("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",d));if(!s(m))throw new TypeError(v("null2V",m));return B(d,t,o,1,i,E(m),m)}export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..62313b5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.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/* 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 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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 8\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 2\n*/\nfunction arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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 v = vectorWithDType( 10, 'float64', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 10\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'generic'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( {}, 'float64', null );\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\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: new 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: new 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: new 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: new 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: new Vector( Iterable )\n\tif ( isIterableLike( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = iterator2array( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( iterator2array( arg ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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: new 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* @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 v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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: new 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: new 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: new Vector( arg0, arg1 )\n\tif ( nargs === 2 ) {\n\t\t// Case: new Vector( dtype, options )\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\treturn vectorWithDType( 0, arg0, arg1 );\n\t\t}\n\t\t// Case: new 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: new 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: new Vector( arg0, options )\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: new Vector( arg0, arg1, arg2 )\n\tif ( nargs === 3 ) {\n\t\t// Case: new 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: new Vector( arg0, dtype, options )\n\t\tif ( isDataType( arg1 ) ) {\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: new 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: new Vector( ArrayBuffer, byteOffset, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: new Vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'null2F', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t}\n\targ3 = arguments[ 3 ];\n\n\t// Case: new 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: new 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: new 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: new 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: new 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"],"names":["DEFAULT_DTYPE","defaults","get","DEFAULT_ORDER","isGenericDataType","dtype","isBinaryDataType","resolveOrder","options","hasOwnProp","order","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","TypeError","format","bytesPerElement","arraybuffer2buffer","typedarray","strides2offset","arguments","ndarray","vectorWithDType","arg","opts","isNonNegativeInteger","isBuffer","copy","copyBuffer","isCollection","array2buffer","isArrayBuffer","byteLength","isIterableLike","iterator2array","isPlainObject","Vector","nargs","arg0","arg1","arg2","arg3","arg4","out","isDataType"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index da051ee..0000000 --- a/lib/index.js +++ /dev/null @@ -1,124 +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 Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ce26213..0000000 --- a/lib/main.js +++ /dev/null @@ -1,561 +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 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 4, 1, 0, 'row-major' ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float32', buf, 8, 1, 0, 'row-major' ); -* // returns -* -* var len = v.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 4, -1, 32, 'row-major' ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = arraybuffer2vector( 'float64', buf, 2, -1, 24, 'row-major' ); -* // returns -* -* var len = v.length; -* // returns 2 -*/ -function arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) { - 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 ) { - N *= -1; - o -= N * bytesPerElement( dtype ); - } - // 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 v = vectorWithDType( 10, 'float64', {} ); -* // returns -* -* var len = v.length; -* // returns 10 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'generic' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = vectorWithDType( buf, 'float64', {} ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var v = vectorWithDType( {}, 'float64', null ); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var array2iterator = require( '@stdlib/array-to-iterator' ); -* -* var v = vectorWithDType( array2iterator( [ 1, 2, 3, 4 ] ), 'generic', {} ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // 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: new Vector( length ) - if ( isNonNegativeInteger( arg ) ) { - buf = buffer( dtype, arg ); - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: new 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: new 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: new Vector( ArrayBuffer ) - if ( isArrayBuffer( arg ) ) { - return arraybuffer2vector( dtype, arg, arg.byteLength/bytesPerElement( dtype ), 1, 0, resolveOrder( opts ), opts ); - } - // Case: new Vector( Iterable ) - if ( isIterableLike( arg ) ) { - if ( isGenericDataType( dtype ) ) { - buf = iterator2array( arg ); - } else if ( isBinaryDataType( dtype ) ) { - buf = array2buffer( iterator2array( arg ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length - } else { - buf = typedarray( arg, dtype ); - } - return new ndarray( dtype, buf, [ buf.length ], [ 1 ], 0, resolveOrder( opts ), opts ); - } - // Case: new 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). -* -* @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 v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -*/ -function Vector() { - var nargs; - var arg0; - var arg1; - var arg2; - var arg3; - var arg4; - var buf; - var out; - - nargs = arguments.length; - - // Case: new 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: new 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: new Vector( arg0, arg1 ) - if ( nargs === 2 ) { - // Case: new Vector( dtype, options ) - if ( isDataType( arg0 ) ) { - return vectorWithDType( 0, arg0, arg1 ); - } - // Case: new 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: new Vector( ArrayBuffer, byteOffset ) - if ( isNonNegativeInteger( arg1 ) ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER ); - } - // Case: new Vector( arg0, options ) - 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: new Vector( arg0, arg1, arg2 ) - if ( nargs === 3 ) { - // Case: new Vector( ArrayBuffer, byteOffset, dtype ) - if ( isDataType( arg2 ) ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER ); - } - // Case: new Vector( arg0, dtype, options ) - if ( isDataType( arg1 ) ) { - 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: new Vector( ArrayBuffer, byteOffset, arg2 ) - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - // Case: new Vector( ArrayBuffer, byteOffset, options ) - if ( isPlainObject( arg2 ) ) { - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); - } - // Case: new Vector( ArrayBuffer, byteOffset, length ) - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', arg2 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER ); - } - arg3 = arguments[ 3 ]; - - // Case: new Vector( ArrayBuffer, byteOffset, arg2, arg3 ) - if ( nargs === 4 ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - // Case: new Vector( ArrayBuffer, byteOffset, length, dtype ) - if ( isNonNegativeInteger( arg2 ) ) { - if ( isDataType( arg3 ) ) { - return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, DEFAULT_ORDER ); - } - // Case: new Vector( ArrayBuffer, byteOffset, length, options ) - if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'null2V', arg3 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); - } - // Case: new 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( 'null2V', arg3 ) ); - } - return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); - } - arg4 = arguments[ 4 ]; - - // Case: new Vector( ArrayBuffer, byteOffset, length, dtype, options ) - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', arg4 ) ); - } - return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); -} - - -// EXPORTS // - -module.exports = Vector; diff --git a/package.json b/package.json index 6818f20..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,59 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..7674ef3 --- /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.js b/test/test.js deleted file mode 100644 index 28e72d2..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +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 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(); -}); - -// FIXME: add tests From eceb0dd9d8f45409e0954bfd2c521fd9ed2da051 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 04:35:19 +0000 Subject: [PATCH 03/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 30 +++++++++++++++--------------- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index 1d73f85..55e14d2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -496,7 +496,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER ); } @@ -514,10 +514,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER ); } @@ -531,10 +531,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, options ) if ( isPlainObject( arg2 ) ) { @@ -542,7 +542,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length ) if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER ); } @@ -551,10 +551,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -563,7 +563,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -572,7 +572,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -580,19 +580,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 8a4b6b7..b6c6377 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From e6b6ff344fedd5f46256f01e8067e593489d1d7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 04:35:41 +0000 Subject: [PATCH 04/69] Remove files --- index.d.ts | 556 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5403 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 0babe14..0000000 --- a/index.d.ts +++ /dev/null @@ -1,556 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { Iterator } from '@stdlib/types/iter'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector(); -* // returns -* -* var len = numel( arr ); -* // returns 0 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 'float32' ); -* // returns -* -* var len = numel( arr ); -* // returns 0 -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 'float32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 0 -* -* var dt = getDType( arr ); -* // returns 'float32' -*/ -declare function vector( dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( {} ); -* // returns -* -* var len = numel( arr ); -* // returns 0 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -declare function vector( options: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param length - vector length -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 2 ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 2, 'float32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 2, 'float32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -*/ -declare function vector( length: number, dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param length - vector length -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( 2, {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -declare function vector( length: number, options: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( [ 1, 2 ], 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( [ 1, 2 ], 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -*/ -declare function vector( obj: Collection | AccessorArrayLike | Iterator, dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* -* var arr = vector( [ 1.0, 2.0 ], {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -declare function vector( obj: Collection | AccessorArrayLike | Iterator, options: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 'float32' ); -* // returns -* -* var len = numel( arr ); -* // returns 4 -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 'float32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 4 -* -* var dt = getDType( arr ); -* // returns 'float32' -*/ -declare function vector( buffer: ArrayBuffer, dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -declare function vector( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 8 ); -* // returns -* -* var len = numel( arr ); -* // returns 1 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 8, 'float32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 8, 'float32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -*/ -declare function vector( buffer: ArrayBuffer, byteOffset?: number, dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 8 ); -* // returns -* -* var len = numel( arr ); -* // returns 1 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = vector( buf, 8, {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float32' -*/ -declare function vector( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2 ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -*/ -declare function vector( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T, options?: Options ): TypedDataTypeMap[T]; - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns one-dimensional ndarray -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'float64' -*/ -declare function vector( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 90815e8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import l 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/assert-has-own-property@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var w=u.get("dtypes.default"),c=u.get("order");function T(r){return"generic"===r}function x(r){return"binary"===r}function E(r){return o(r,"order")?r.order:c}function B(r,e,t,n,s,i,l){var o,a,m,u,j;if(T(r))throw new TypeError(v("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return j=s,u=t*n,n<0&&(j-=(u*=-1)*g(r)),o=x(r)?h(e,j,u):d(e,j,u,r),j=p(a=[t],m=[n]),arguments.length>6?new f(r,o,a,m,j,i,l):new f(r,o,a,m,j,i)}function V(l,o,u){var p,h;return p=null===u?{}:u,r(l)?(h=a(o,l),new f(o,h,[h.length],[1],0,E(p),p)):i(l)?(h=T(o)?m(l):x(o)?y(l):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):t(l)?(h=T(o)?m(l):x(o)?j(l):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):n(l)?B(o,l,l.byteLength/g(o),1,0,E(p),p):e(l)?(h=T(o)?b(l):x(o)?j(b(l)):d(l,o),new f(o,h,[h.length],[1],0,E(p),p)):null===u&&s(l)?(h=a(o,0),new f(o,h,[h.length],[1],0,E(l),l)):null}function F(){var e,t,i,o,d,m,u,p;if(0===(e=arguments.length))return u=a(w,0),new f(w,u,[u.length],[1],0,c);if(t=arguments[0],1===e){if(l(t))return V(0,t,null);if(null===(p=V(t,w,null)))throw new TypeError(v("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return p}if(i=arguments[1],2===e){if(l(t))return V(0,t,i);if(l(i)){if(null===(p=V(t,i,null)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(r(i)){if(!n(t))throw new TypeError(v("null2B",t));return B(w,t,(t.byteLength-i)/g(w),1,i,c)}if(null===(p=V(t,w,i)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(o=arguments[2],3===e){if(l(o)){if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));return B(o,t,(t.byteLength-i)/g(o),1,i,c)}if(l(i)){if(null===(p=V(t,i,o)))throw new TypeError(v("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return p}if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(s(o))return B(w,t,(t.byteLength-i)/g(w),1,i,E(o),o);if(!r(o))throw new TypeError(v("null2F",o));return B(w,t,o,1,i,c)}if(d=arguments[3],4===e){if(!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(r(o)){if(l(d))return B(d,t,o,1,i,c);if(!s(d))throw new TypeError(v("null2V",d));return B(w,t,o,1,i,E(d),d)}if(!l(o))throw new TypeError(v("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!s(d))throw new TypeError(v("null2V",d));return B(o,t,(t.byteLength-i)/g(o),1,i,E(d),d)}if(m=arguments[4],!n(t))throw new TypeError(v("null2B",t));if(!r(i))throw new TypeError(v("null2C",i));if(!r(o))throw new TypeError(v("null2F",o));if(!l(d))throw new TypeError(v("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",d));if(!s(m))throw new TypeError(v("null2V",m));return B(d,t,o,1,i,E(m),m)}export{F as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 62313b5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.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/* 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 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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 8\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* @example\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 = v.length;\n* // returns 2\n*/\nfunction arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, options ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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 v = vectorWithDType( 10, 'float64', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 10\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( [ 1, 2, 3, 4 ], 'generic', {} );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'generic'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = vectorWithDType( {}, 'float64', null );\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\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 = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\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: new 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: new 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: new 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: new 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: new Vector( Iterable )\n\tif ( isIterableLike( arg ) ) {\n\t\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = iterator2array( arg );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = array2buffer( iterator2array( arg ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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: new 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* @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 v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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: new 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: new 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: new Vector( arg0, arg1 )\n\tif ( nargs === 2 ) {\n\t\t// Case: new Vector( dtype, options )\n\t\tif ( isDataType( arg0 ) ) {\n\t\t\treturn vectorWithDType( 0, arg0, arg1 );\n\t\t}\n\t\t// Case: new 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: new 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: new Vector( arg0, options )\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: new Vector( arg0, arg1, arg2 )\n\tif ( nargs === 3 ) {\n\t\t// Case: new 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: new Vector( arg0, dtype, options )\n\t\tif ( isDataType( arg1 ) ) {\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: new 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: new Vector( ArrayBuffer, byteOffset, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: new Vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'null2F', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\n\t}\n\targ3 = arguments[ 3 ];\n\n\t// Case: new 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: new 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: new 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: new 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: new 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"],"names":["DEFAULT_DTYPE","defaults","get","DEFAULT_ORDER","isGenericDataType","dtype","isBinaryDataType","resolveOrder","options","hasOwnProp","order","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","TypeError","format","bytesPerElement","arraybuffer2buffer","typedarray","strides2offset","arguments","ndarray","vectorWithDType","arg","opts","isNonNegativeInteger","isBuffer","copy","copyBuffer","isCollection","array2buffer","isArrayBuffer","byteLength","isIterableLike","iterator2array","isPlainObject","Vector","nargs","arg0","arg1","arg2","arg3","arg4","out","isDataType"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7674ef3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aa2e5019b8d09ef3cd3220169e944575fd9044dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 04:36:34 +0000 Subject: [PATCH 05/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 133 - lib/main.js | 603 --- lib/validate.js | 82 - package.json | 88 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 41 - 48 files changed, 4889 insertions(+), 5946 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 a8afc4c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var N=D(function(yr,I){"use strict";var J=require("@stdlib/assert-is-plain-object"),P=require("@stdlib/assert-has-own-property"),K=require("@stdlib/assert-is-boolean").isPrimitive,Q=require("@stdlib/ndarray-base-assert-is-index-mode"),X=require("@stdlib/ndarray-base-assert-is-order"),O=require("@stdlib/string-format");function Z(e,r){return J(r)?P(r,"readonly")&&(e.readonly=r.readonly,!K(e.readonly))?new TypeError(O("invalid option. `%s` option must be a boolean. Option: `%s`.","readonly",e.readonly)):P(r,"mode")&&(e.mode=r.mode,!Q(e.mode))?new TypeError(O("invalid option. `%s` option must be a valid index mode. Option: `%s`.","mode",e.mode)):P(r,"order")&&(e.order=r.order,!X(e.order))?new TypeError(O("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",e.order)):null:new TypeError(O("invalid argument. Options argument must be an object. Value: `%s`.",r))}I.exports=Z});var x=D(function(br,U){"use strict";var w=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,$=require("@stdlib/assert-is-iterable-like"),rr=require("@stdlib/assert-is-collection"),T=require("@stdlib/assert-is-arraybuffer"),B=require("@stdlib/assert-is-plain-object"),er=require("@stdlib/assert-is-buffer"),b=require("@stdlib/ndarray-base-assert-is-data-type"),ar=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),A=require("@stdlib/array-typed"),R=require("@stdlib/array-base-copy"),h=require("@stdlib/ndarray-ctor"),C=require("@stdlib/ndarray-defaults"),nr=require("@stdlib/ndarray-base-strides2offset"),tr=require("@stdlib/buffer-from-arraybuffer"),M=require("@stdlib/buffer-from-array"),ir=require("@stdlib/buffer-from-buffer"),_=require("@stdlib/array-from-iterator"),p=require("@stdlib/ndarray-base-bytes-per-element"),z=require("@stdlib/symbol-iterator"),f=require("@stdlib/string-format"),m=C.get("dtypes.default"),E=C.get("order");function j(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return ar(e,"order")?e.order:E}function y(e,r,t,n,a,u,l){var i,s,o,V,d;if(j(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=a,V=t*n,n<0&&(V*=-1,d-=V*p(e)),F(e)?i=tr(r,d,V):i=A(r,d,V,e),s=[t],o=[n],d=nr(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function q(e,r,t){var n,a;return t===null?n={}:n=t,w(e)?(a=k(r,e),new h(r,a,[a.length],[1],0,g(n),n)):er(e)?(j(r)?a=R(e):F(r)?a=ir(e):a=A(e,r),new h(r,a,[a.length],[1],0,g(n),n)):rr(e)?(j(r)?a=R(e):F(r)?a=M(e):a=A(e,r),new h(r,a,[a.length],[1],0,g(n),n)):T(e)?y(r,e,e.byteLength/p(r),1,0,g(n),n):$(e)?(j(r)?(a=e[z](),a=_(a)):F(r)?(a=e[z](),a=M(_(a))):a=A(e,r),new h(r,a,[a.length],[1],0,g(n),n)):t===null&&B(e)?(a=k(r,0),new h(r,a,[a.length],[1],0,g(e),e)):null}function ur(){var e,r,t,n,a,u,l,i;if(e=arguments.length,e===0)return l=k(m,0),new h(m,l,[l.length],[1],0,E);if(r=arguments[0],e===1){if(b(r))return q(0,r,null);if(i=q(r,m,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(b(r))return q(0,r,t);if(b(t)){if(i=q(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!T(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return y(m,r,(r.byteLength-t)/p(m),1,t,E)}if(i=q(r,m,t),i===null)throw new TypeError(f("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(b(n)){if(!T(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return y(n,r,(r.byteLength-t)/p(n),1,t,E)}if(b(t)){if(i=q(r,t,n),i===null)throw new TypeError(f("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(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(B(n))return y(m,r,(r.byteLength-t)/p(m),1,t,g(n),n);if(!w(n))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));return y(m,r,n,1,t,E)}if(a=arguments[3],e===4){if(!T(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(n)){if(b(a))return y(a,r,n,1,t,E);if(!B(a))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return y(m,r,n,1,t,g(a),a)}if(!b(n))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",n));if(!B(a))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return y(n,r,(r.byteLength-t)/p(n),1,t,g(a),a)}if(u=arguments[4],!T(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(n))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",n));if(!b(a))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!B(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return y(a,r,n,1,t,g(u),u)}U.exports=ur});var W=D(function(hr,S){"use strict";var L=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,or=require("@stdlib/assert-is-iterable-like"),Y=require("@stdlib/assert-is-arraybuffer"),G=require("@stdlib/assert-is-collection"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),v=x();function vr(e,r){var t,n;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(n=c(t,r),n))throw n;return a;function a(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return v(e,u);if(l>3){if(o=c(u,arguments[3]),o)throw o;return v(arguments[0],arguments[1],arguments[2],e,u)}if(l===3){if(L(arguments[2]))return v(arguments[0],arguments[1],arguments[2],e,u);if(o=c(u,arguments[2]),o)throw o;return v(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return v(i,e,u)}if(Y(i)){if(L(s))return v(i,s,e,u);if(o=c(u,s),o)throw o;return v(i,e,u)}if(G(i)){if(o=c(u,s),o)throw o;return v(i,e,u)}if(o=c(u,s),o)throw o;return v(i,e,u)}if(i=arguments[0],L(i)||Y(i)||G(i)||or(i))return v(i,e,u);if(o=c(u,i),o)throw o;return v(e,u)}}S.exports=vr});var mr=require("@stdlib/utils-define-nonenumerable-read-only-property"),gr=W(),H=x();mr(H,"factory",gr);module.exports=H; -/** -* @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 68790c0..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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\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\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\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, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\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 Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAc,QAAS,2CAA4C,EACnEC,EAAU,QAAS,sCAAuC,EAC1DC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACN,EAAWK,EAAK,QAAS,GACvB,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAGvHN,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACL,EAAaI,EAAK,IAAK,GACrB,IAAI,UAAWF,EAAQ,wEAAyE,OAAQE,EAAK,IAAK,CAAE,EAGxHN,EAAYO,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACJ,EAASG,EAAK,KAAM,GAClB,IAAI,UAAWF,EAAQ,qEAAsE,QAASE,EAAK,KAAM,CAAE,EAGrH,KApBC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAqBhH,CAKAT,EAAO,QAAUO,ICjFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAiB,QAAS,iCAAkC,EAC5DC,GAAe,QAAS,8BAA+B,EACvDC,EAAgB,QAAS,+BAAgC,EACzDC,EAAgB,QAAS,gCAAiC,EAC1DC,GAAW,QAAS,0BAA2B,EAC/CC,EAAa,QAAS,0CAA2C,EACjEC,GAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,6BAA8B,EAChDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAO,QAAS,yBAA0B,EAC1CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,GAAiB,QAAS,qCAAsC,EAChEC,GAAqB,QAAS,iCAAkC,EAChEC,EAAe,QAAS,2BAA4B,EACpDC,GAAa,QAAS,4BAA6B,EACnDC,EAAiB,QAAS,6BAA8B,EACxDC,EAAkB,QAAS,wCAAyC,EACpEC,EAAkB,QAAS,yBAA0B,EACrDC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBT,EAAS,IAAK,gBAAiB,EAC/CU,EAAgBV,EAAS,IAAK,OAAQ,EAY1C,SAASW,EAAmBC,EAAQ,CACnC,OAASA,IAAU,SACpB,CASA,SAASC,EAAkBD,EAAQ,CAClC,OAASA,IAAU,QACpB,CASA,SAASE,EAAcC,EAAU,CAChC,OAAKpB,GAAYoB,EAAS,OAAQ,EAC1BA,EAAQ,MAETL,CACR,CA8DA,SAASM,EAAoBJ,EAAOhB,EAAQqB,EAAQC,EAAQC,EAAYC,EAAOL,EAAU,CACxF,IAAIM,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKd,EAAmBC,CAAM,EAC7B,MAAM,IAAI,UAAWJ,EAAQ,2FAA4FI,CAAM,CAAE,EAwBlI,OAtBAa,EAAIN,EAGJK,EAAIP,EAASC,EAGRA,EAAS,IACbM,GAAK,GACLC,GAAKD,EAAIlB,EAAiBM,CAAM,GAG5BC,EAAkBD,CAAM,EAC5BS,EAAMnB,GAAoBN,EAAQ6B,EAAGD,CAAE,EAEvCH,EAAMxB,EAAYD,EAAQ6B,EAAGD,EAAGZ,CAAM,EAGvCU,EAAK,CAAEL,CAAO,EACdM,EAAK,CAAEL,CAAO,EACdO,EAAIxB,GAAgBqB,EAAIC,CAAG,EAGtB,UAAU,OAAS,EAChB,IAAIxB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,EAAOL,CAAQ,EAEpD,IAAIhB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,CAAM,CAClD,CAiFA,SAASM,EAAiBC,EAAKf,EAAOG,EAAU,CAC/C,IAAIa,EACAP,EASJ,OANKN,IAAY,KAChBa,EAAO,CAAC,EAERA,EAAOb,EAGH3B,EAAsBuC,CAAI,GAC9BN,EAAMzB,EAAQgB,EAAOe,CAAI,EAClB,IAAI5B,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFnC,GAAUkC,CAAI,GACbhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMjB,GAAYuB,CAAI,EAEtBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFtC,GAAcqC,CAAI,GACjBhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMlB,EAAcwB,CAAI,EAExBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFrC,EAAeoC,CAAI,EAChBX,EAAoBJ,EAAOe,EAAKA,EAAI,WAAWrB,EAAiBM,CAAM,EAAG,EAAG,EAAGE,EAAcc,CAAK,EAAGA,CAAK,EAG7GvC,EAAgBsC,CAAI,GACnBhB,EAAmBC,CAAM,GAC7BS,EAAMM,EAAKpB,CAAgB,EAAE,EAC7Bc,EAAMhB,EAAgBgB,CAAI,GACfR,EAAkBD,CAAM,GACnCS,EAAMM,EAAKpB,CAAgB,EAAE,EAC7Bc,EAAMlB,EAAcE,EAAgBgB,CAAI,CAAE,GAE1CA,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFb,IAAY,MAAQvB,EAAemC,CAAI,GAC3CN,EAAMzB,EAAQgB,EAAO,CAAE,EAChB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAca,CAAI,EAAGA,CAAI,GAE7E,IACR,CAyHA,SAASE,IAAS,CACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAd,EACAe,EAKJ,GAHAN,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAT,EAAMzB,EAAQa,EAAe,CAAE,EACxB,IAAIV,EAASU,EAAeY,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGX,CAAc,EAKjF,GAHAqB,EAAO,UAAW,CAAE,EAGfD,IAAU,EAAI,CAClB,GAAKpC,EAAYqC,CAAK,EACrB,OAAOL,EAAiB,EAAGK,EAAM,IAAK,EAGvC,GADAK,EAAMV,EAAiBK,EAAMtB,EAAe,IAAK,EAC5C2B,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,6IAA8IuB,CAAK,CAAE,EAEnL,OAAOK,CACR,CAIA,GAHAJ,EAAO,UAAW,CAAE,EAGfF,IAAU,EAAI,CAElB,GAAKpC,EAAYqC,CAAK,EACrB,OAAOL,EAAiB,EAAGK,EAAMC,CAAK,EAGvC,GAAKtC,EAAYsC,CAAK,EAAI,CAEzB,GADAI,EAAMV,EAAiBK,EAAMC,EAAM,IAAK,EACnCI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAKhD,EAAsB4C,CAAK,EAAI,CACnC,GAAK,CAACzC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,OAAOf,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMtB,CAAc,CACjI,CAGA,GADA0B,EAAMV,EAAiBK,EAAMtB,EAAeuB,CAAK,EAC5CI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAIA,GAHAH,EAAO,UAAW,CAAE,EAGfH,IAAU,EAAI,CAElB,GAAKpC,EAAYuC,CAAK,EAAI,CACzB,GAAK,CAAC1C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,OAAOhB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMtB,CAAc,CAC/G,CAEA,GAAKhB,EAAYsC,CAAK,EAAI,CAEzB,GADAI,EAAMV,EAAiBK,EAAMC,EAAMC,CAAK,EACnCG,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAK,CAAC7C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAKxC,EAAeyC,CAAK,EACxB,OAAOjB,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMlB,EAAcmB,CAAK,EAAGA,CAAK,EAG9I,GAAK,CAAC7C,EAAsB6C,CAAK,EAChC,MAAM,IAAI,UAAWzB,EAAQ,uEAAwEyB,CAAK,CAAE,EAE7G,OAAOjB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMtB,CAAc,CAC9E,CAIA,GAHAwB,EAAO,UAAW,CAAE,EAGfJ,IAAU,EAAI,CAClB,GAAK,CAACvC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAK5C,EAAsB6C,CAAK,EAAI,CACnC,GAAKvC,EAAYwC,CAAK,EACrB,OAAOlB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMtB,CAAc,EAGrE,GAAK,CAAClB,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC3F,CAEA,GAAK,CAACxC,EAAYuC,CAAK,EACtB,MAAM,IAAI,UAAWzB,EAAQ,0FAA2FyB,CAAK,CAAE,EAEhI,GAAK,CAACzC,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC5H,CAIA,GAHAC,EAAO,UAAW,CAAE,EAGf,CAAC5C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,GAAK,CAAC5C,EAAsB6C,CAAK,EAChC,MAAM,IAAI,UAAWzB,EAAQ,uEAAwEyB,CAAK,CAAE,EAE7G,GAAK,CAACvC,EAAYwC,CAAK,EACtB,MAAM,IAAI,UAAW1B,EAAQ,2FAA4F0B,CAAK,CAAE,EAEjI,GAAK,CAAC1C,EAAe2C,CAAK,EACzB,MAAM,IAAI,UAAW3B,EAAQ,qEAAsE2B,CAAK,CAAE,EAE3G,OAAOnB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMlB,EAAcqB,CAAK,EAAGA,CAAK,CAClF,CAKAhD,EAAO,QAAU0C,KC1lBjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,GAAiB,QAAS,iCAAkC,EAC5DC,EAAgB,QAAS,+BAAgC,EACzDC,EAAe,QAAS,8BAA+B,EACvDC,GAAa,QAAS,0CAA2C,EACjEC,GAAe,QAAS,uBAAwB,EAChDC,GAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAO,IAmGX,SAASC,GAASC,EAAOC,EAAU,CAClC,IAAIC,EACAC,EACJ,GAAK,CAACT,GAAYM,CAAM,EACvB,MAAM,IAAI,UAAWJ,GAAQ,+EAAgFI,CAAM,CAAE,EAGtH,GADAE,EAAO,CAAC,EACH,UAAU,OAAS,IACvBC,EAAMN,EAAUK,EAAMD,CAAQ,EACzBE,GACJ,MAAMA,EAGR,OAAOC,EAgBP,SAASA,GAAS,CACjB,IAAIH,EACAI,EACAC,EACAC,EACAJ,EAMJ,GAJAF,EAAUN,GAAc,CAAC,EAAGO,CAAK,EACjCG,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAOP,EAAME,EAAOC,CAAQ,EAG7B,GAAKI,EAAQ,EAAI,CAEhB,GADAF,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7E,CAEA,GAAKI,IAAU,EAAI,CAElB,GAAKf,EAAsB,UAAW,CAAE,CAAE,EACzC,OAAOQ,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,EAI7E,GADAE,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7D,CAEA,GAAKI,IAAU,EAAI,CAKlB,GAJAC,EAAO,UAAW,CAAE,EACpBC,EAAO,UAAW,CAAE,EAGfjB,EAAsBgB,CAAK,EAAI,CAEnC,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKT,EAAec,CAAK,EAAI,CAE5B,GAAKhB,EAAsBiB,CAAK,EAC/B,OAAOT,EAAMQ,EAAMC,EAAMP,EAAOC,CAAQ,EAIzC,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKR,EAAca,CAAK,EAAI,CAE3B,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAGA,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAKA,GAHAK,EAAO,UAAW,CAAE,EAInBhB,EAAsBgB,CAAK,GAC3Bd,EAAec,CAAK,GACpBb,EAAca,CAAK,GACnBf,GAAgBe,CAAK,EAErB,OAAOR,EAAMQ,EAAMN,EAAOC,CAAQ,EAInC,GADAE,EAAMN,EAAUI,EAASK,CAAK,EACzBH,EACJ,MAAMA,EAEP,OAAOL,EAAME,EAAOC,CAAQ,CAC7B,CACD,CAKAZ,EAAO,QAAUU,KC9IjB,IAAIS,GAAc,QAAS,uDAAwD,EAC/EC,GAAU,IACVC,EAAO,IAKXF,GAAaE,EAAM,UAAWD,EAAQ,EAKtC,OAAO,QAAUC", - "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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 001fb71..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}}( 16 ); - > 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 6433bfa..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 objects... -{ - 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 objects... -{ - 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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 9733226..cc687c7 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..52d7b8e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(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 F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var l,a,m,f,u;if(A(r))throw new TypeError(d("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),l=L(r)?w(e,u,f):y(e,u,f,r),u=g(a=[t],m=[n]),arguments.length>6?new b(r,l,a,m,u,s,o):new b(r,l,a,m,u,s)}function O(r,s,o){var d,a;return d=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(d),d)):p(r)?(a=A(s)?j(r):L(s)?x(r):y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(d),d):t(r)?(A(s)?(a=r[V](),a=T(a)):L(s)?(a=r[V](),a=c(T(a))):a=y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):null===o&&l(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,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(i=arguments[1],2===r){if(s(t))return O(0,t,i);if(s(i)){if(null===(u=O(t,i,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(i)){if(!n(t))throw new TypeError(d("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===(u=O(t,F,i)))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(s(o)){if(!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===(u=O(t,i,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(i))throw new TypeError(d("null2C",i));if(l(o))return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o);if(!e(o))throw new TypeError(d("null2F",o));return z(F,t,o,1,i,k)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!l(a))throw new TypeError(d("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(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-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));if(!e(o))throw new TypeError(d("null2F",o));if(!s(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,i,C(m),m)}function P(r,l){var a,m;if(!s(r))throw new TypeError(d("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,l)))throw m;return function(){var s,d,l,m,f;if(s=o({},a),d=arguments.length,0===d)return M(r,s);if(d>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===d){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===d){if(m=arguments[1],e(l=arguments[0])){if(f=B(s,m))throw f;return M(l,r,s)}if(n(l)){if(e(m))return M(l,m,r,s);if(f=B(s,m))throw f;return M(l,r,s)}if(i(l)){if(f=B(s,m))throw f;return M(l,r,s)}if(f=B(s,m))throw f;return M(l,r,s)}if(l=arguments[0],e(l)||n(l)||i(l)||t(l))return M(l,r,s);if(f=B(s,l),f)throw f;return M(r,s)}}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..9cdbe06 --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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\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\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\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, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'null2F', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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":";;k/EAqDA,SAASA,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,cACzBD,EAAKI,SAAWH,EAAQG,UAClBC,EAAWL,EAAKI,WACd,IAAIE,UAAWC,EAAQ,SAAU,WAAYP,EAAKI,WAGtDD,EAAYF,EAAS,UACzBD,EAAKQ,KAAOP,EAAQO,MACdC,EAAaT,EAAKQ,OAChB,IAAIF,UAAWC,EAAQ,wEAAyE,OAAQP,EAAKQ,OAGjHL,EAAYF,EAAS,WACzBD,EAAKU,MAAQT,EAAQS,OACfC,EAASX,EAAKU,QACZ,IAAIJ,UAAWC,EAAQ,qEAAsE,QAASP,EAAKU,QAG7G,KApBC,IAAIJ,UAAWC,EAAQ,SAAUN,GAqB1C,CC3BA,IAAIW,EAAgBC,EAASC,IAAK,kBAC9BC,EAAgBF,EAASC,IAAK,SAYlC,SAASE,EAAmBC,GAC3B,MAAmB,YAAVA,CACV,CASA,SAASC,EAAkBD,GAC1B,MAAmB,WAAVA,CACV,CASA,SAASE,EAAclB,GACtB,OAAKE,EAAYF,EAAS,SAClBA,EAAQS,MAETK,CACR,CA8DA,SAASK,EAAoBH,EAAOI,EAAQC,EAAQC,EAAQC,EAAYd,EAAOT,GAC9E,IAAIwB,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,EAAmBC,GACvB,MAAM,IAAIX,UAAWC,EAAQ,2FAA4FU,IAwB1H,OAtBAY,EAAIL,EAGJI,EAAIN,EAASC,EAGRA,EAAS,IAEbM,IADAD,IAAM,GACGE,EAAiBb,IAI1BQ,EADIP,EAAkBD,GAChBc,EAAoBV,EAAQQ,EAAGD,GAE/BI,EAAYX,EAAQQ,EAAGD,EAAGX,GAKjCY,EAAII,EAFJP,EAAK,CAAEJ,GACPK,EAAK,CAAEJ,IAIFW,UAAUZ,OAAS,EAChB,IAAIa,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAAOT,GAE5C,IAAIkC,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAC5C,CAiFA,SAAS0B,EAAiBC,EAAKpB,EAAOhB,GACrC,IAAID,EACAyB,EASJ,OALCzB,EADgB,OAAZC,EACG,CAAA,EAEAA,EAGHqC,EAAsBD,IAC1BZ,EAAMJ,EAAQJ,EAAOoB,GACd,IAAIF,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5EuC,EAAUF,IAEbZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvBwB,EAAYJ,GAEZL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E0C,EAAcL,IAEjBZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvB0B,EAAcN,GAEdL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E4C,EAAeP,GACZjB,EAAoBH,EAAOoB,EAAKA,EAAIQ,WAAWf,EAAiBb,GAAS,EAAG,EAAGE,EAAcnB,GAAQA,GAGxG8C,EAAgBT,IACfrB,EAAmBC,IACvBQ,EAAMY,EAAKU,KACXtB,EAAMuB,EAAgBvB,IACXP,EAAkBD,IAC7BQ,EAAMY,EAAKU,KACXtB,EAAMkB,EAAcK,EAAgBvB,KAEpCA,EAAMO,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAGhE,OAAZC,GAAoBgD,EAAeZ,IACvCZ,EAAMJ,EAAQJ,EAAO,GACd,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAckB,GAAOA,IAEzE,IACR,CAyHA,SAASa,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA/B,EACAgC,EAKJ,GAAe,KAHfN,EAAQjB,UAAUZ,QAKjB,OADAG,EAAMJ,EAAQT,EAAe,GACtB,IAAIuB,EAASvB,EAAea,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGP,GAKnE,GAHAqC,EAAOlB,UAAW,GAGH,IAAViB,EAAc,CAClB,GAAKO,EAAYN,GAChB,OAAOhB,EAAiB,EAAGgB,EAAM,MAGlC,GAAa,QADbK,EAAMrB,EAAiBgB,EAAMxC,EAAe,OAE3C,MAAM,IAAIN,UAAWC,EAAQ,6IAA8I6C,IAE5K,OAAOK,CACP,CAID,GAHAJ,EAAOnB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYN,GAChB,OAAOhB,EAAiB,EAAGgB,EAAMC,GAGlC,GAAKK,EAAYL,GAAS,CAEzB,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMC,EAAM,OAElC,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,GAAKnB,EAAsBe,GAAS,CACnC,IAAMT,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,OAAOhC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMtC,EAClH,CAGD,GAAa,QADb0C,EAAMrB,EAAiBgB,EAAMxC,EAAeyC,IAE3C,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAID,GAHAH,EAAOpB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYJ,GAAS,CACzB,IAAMV,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMtC,EAChG,CAED,GAAK2C,EAAYL,GAAS,CAEzB,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMC,EAAMC,IAElC,MAAM,IAAIhD,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,IAAMb,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKJ,EAAeK,GACnB,OAAOlC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMlC,EAAcmC,GAAQA,GAGzI,IAAMhB,EAAsBgB,GAC3B,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,OAAOlC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMtC,EAC/D,CAID,GAHAwC,EAAOrB,UAAW,GAGH,IAAViB,EAAc,CAClB,IAAMP,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAAS,CACnC,GAAKI,EAAYH,GAChB,OAAOnC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMtC,GAGvD,IAAMkC,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMlC,EAAcoC,GAAQA,EACrF,CAED,IAAMG,EAAYJ,GACjB,MAAM,IAAIhD,UAAWC,EAAQ,0FAA2F+C,IAEzH,IAAML,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMlC,EAAcoC,GAAQA,EACtH,CAID,GAHAC,EAAOtB,UAAW,IAGZU,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,IAAMf,EAAsBgB,GAC3B,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,IAAMI,EAAYH,GACjB,MAAM,IAAIjD,UAAWC,EAAQ,2FAA4FgD,IAE1H,IAAMN,EAAeO,GACpB,MAAM,IAAIlD,UAAWC,EAAQ,SAAUiD,IAExC,OAAOpC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMlC,EAAcqC,GAAQA,EAC7E,CCldA,SAASG,EAAS1C,EAAOhB,GACxB,IAAID,EACA4D,EACJ,IAAMF,EAAYzC,GACjB,MAAM,IAAIX,UAAWC,EAAQ,+EAAgFU,IAG9G,GADAjB,EAAO,CAAA,EACFkC,UAAUZ,OAAS,IACvBsC,EAAM7D,EAAUC,EAAMC,IAErB,MAAM2D,EAGR,OAgBA,WACC,IAAI3D,EACAkD,EACAC,EACAC,EACAO,EAMJ,GAJA3D,EAAU4D,EAAc,GAAI7D,GAC5BmD,EAAQjB,UAAUZ,OAGH,IAAV6B,EACJ,OAAOW,EAAM7C,EAAOhB,GAGrB,GAAKkD,EAAQ,EAAI,CAEhB,GADAS,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpE,CAED,GAAe,IAAVkD,EAAc,CAElB,GAAKb,EAAsBJ,UAAW,IACrC,OAAO4B,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,GAIrE,GADA2D,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpD,CAED,GAAe,IAAVkD,EAAc,CAKlB,GAHAE,EAAOnB,UAAW,GAGbI,EAJLc,EAAOlB,UAAW,IAIkB,CAEnC,GADA0B,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAK2C,EAAeQ,GAAS,CAE5B,GAAKd,EAAsBe,GAC1B,OAAOS,EAAMV,EAAMC,EAAMpC,EAAOhB,GAIjC,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAKyC,EAAcU,GAAS,CAE3B,GADAQ,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAGD,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAKD,GAHAmD,EAAOlB,UAAW,GAIjBI,EAAsBc,IACtBR,EAAeQ,IACfV,EAAcU,IACdN,EAAgBM,GAEhB,OAAOU,EAAMV,EAAMnC,EAAOhB,GAI3B,GADA2D,EAAM7D,EAAUE,EAASmD,GACpBQ,EACJ,MAAMA,EAEP,OAAOE,EAAM7C,EAAOhB,EACpB,CACF,CClIA8D,EAAAD,EAAA,UAAAH"} \ No newline at end of file diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 321f881..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/error-tools-fmtprodmsg' ); -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 6711e26..0000000 --- a/lib/index.js +++ /dev/null @@ -1,133 +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 Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // 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 55e14d2..0000000 --- a/lib/main.js +++ /dev/null @@ -1,603 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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 ) { - 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 ) { - N *= -1; - o -= N * bytesPerElement( dtype ); - } - // 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 ) ) { - if ( isGenericDataType( dtype ) ) { - buf = arg[ ITERATOR_SYMBOL ](); - buf = iterator2array( buf ); - } else if ( isBinaryDataType( dtype ) ) { - buf = arg[ ITERATOR_SYMBOL ](); - buf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length - } else { - buf = typedarray( arg, 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 ) ) { - 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( 'null2B', arg0 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( arg0, options ) - 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, DEFAULT_ORDER ); - } - // Case: vector( arg0, dtype, options ) - if ( isDataType( arg1 ) ) { - 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - // Case: vector( ArrayBuffer, byteOffset, options ) - if ( isPlainObject( arg2 ) ) { - return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); - } - // Case: vector( ArrayBuffer, byteOffset, length ) - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', arg2 ) ); - } - return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER ); - } - arg3 = arguments[ 3 ]; - - // Case: vector( ArrayBuffer, byteOffset, arg2, arg3 ) - if ( nargs === 4 ) { - if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 b6c6377..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,67 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..40bf172 --- /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.js b/test/test.js deleted file mode 100644 index 93217a0..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +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(); -}); - -// FIXME: add tests (see array/typed and ndarray/zeros) From f21de0b163daae06cd541da72ba67d0117566d92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 12:00:06 +0000 Subject: [PATCH 06/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index cc2a6f0..1aed3f2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -484,7 +484,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -499,13 +499,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -520,17 +520,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -540,10 +540,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -551,7 +551,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -560,10 +560,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -572,7 +572,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -581,7 +581,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -589,19 +589,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index a95997c..2801e8d 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 05603811c9060f2c7e02017c7020d6f62168348b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 12:00:24 +0000 Subject: [PATCH 07/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cc687c7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 52d7b8e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(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 F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var l,a,m,f,u;if(A(r))throw new TypeError(d("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),l=L(r)?w(e,u,f):y(e,u,f,r),u=g(a=[t],m=[n]),arguments.length>6?new b(r,l,a,m,u,s,o):new b(r,l,a,m,u,s)}function O(r,s,o){var d,a;return d=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(d),d)):p(r)?(a=A(s)?j(r):L(s)?x(r):y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(d),d):t(r)?(A(s)?(a=r[V](),a=T(a)):L(s)?(a=r[V](),a=c(T(a))):a=y(r,s),new b(s,a,[a.length],[1],0,C(d),d)):null===o&&l(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,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(i=arguments[1],2===r){if(s(t))return O(0,t,i);if(s(i)){if(null===(u=O(t,i,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(i)){if(!n(t))throw new TypeError(d("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===(u=O(t,F,i)))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(s(o)){if(!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===(u=O(t,i,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(i))throw new TypeError(d("null2C",i));if(l(o))return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o);if(!e(o))throw new TypeError(d("null2F",o));return z(F,t,o,1,i,k)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!l(a))throw new TypeError(d("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(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-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(d("null2B",t));if(!e(i))throw new TypeError(d("null2C",i));if(!e(o))throw new TypeError(d("null2F",o));if(!s(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,i,C(m),m)}function P(r,l){var a,m;if(!s(r))throw new TypeError(d("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,l)))throw m;return function(){var s,d,l,m,f;if(s=o({},a),d=arguments.length,0===d)return M(r,s);if(d>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===d){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===d){if(m=arguments[1],e(l=arguments[0])){if(f=B(s,m))throw f;return M(l,r,s)}if(n(l)){if(e(m))return M(l,m,r,s);if(f=B(s,m))throw f;return M(l,r,s)}if(i(l)){if(f=B(s,m))throw f;return M(l,r,s)}if(f=B(s,m))throw f;return M(l,r,s)}if(l=arguments[0],e(l)||n(l)||i(l)||t(l))return M(l,r,s);if(f=B(s,l),f)throw f;return M(r,s)}}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 deleted file mode 100644 index 9cdbe06..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 ) {\n\t\tN *= -1;\n\t\to -= N * bytesPerElement( dtype );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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\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\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\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, options )\n\t\tif ( isPlainObject( arg2 ) ) {\n\t\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 );\n\t\t}\n\t\t// Case: vector( ArrayBuffer, byteOffset, length )\n\t\tif ( !isNonNegativeInteger( arg2 ) ) {\n\t\t\tthrow new TypeError( format( 'null2F', arg2 ) );\n\t\t}\n\t\treturn arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, DEFAULT_ORDER );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 40bf172..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6165b321b3a0f4927e45d16ae988772ccb256c80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 12:01:29 +0000 Subject: [PATCH 08/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 133 - lib/main.js | 612 --- lib/validate.js | 82 - package.json | 99 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - test/test.main.js | 1834 ------- 49 files changed, 4889 insertions(+), 7799 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 9e2e3ef..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var N=D(function(br,I){"use strict";var J=require("@stdlib/assert-is-plain-object"),P=require("@stdlib/assert-has-own-property"),K=require("@stdlib/assert-is-boolean").isPrimitive,Q=require("@stdlib/ndarray-base-assert-is-index-mode"),X=require("@stdlib/ndarray-base-assert-is-order"),B=require("@stdlib/string-format");function Z(e,r){return J(r)?P(r,"readonly")&&(e.readonly=r.readonly,!K(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,!Q(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,!X(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=Z});var x=D(function(yr,U){"use strict";var w=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,$=require("@stdlib/assert-is-iterable-like"),rr=require("@stdlib/assert-is-collection"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),er=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),ar=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=require("@stdlib/array-typed"),R=require("@stdlib/array-base-copy"),h=require("@stdlib/ndarray-ctor"),C=require("@stdlib/ndarray-defaults"),nr=require("@stdlib/ndarray-base-strides2offset"),tr=require("@stdlib/buffer-from-arraybuffer"),M=require("@stdlib/buffer-from-array"),ir=require("@stdlib/buffer-from-buffer"),_=require("@stdlib/array-from-iterator"),p=require("@stdlib/ndarray-base-bytes-per-element"),z=require("@stdlib/symbol-iterator"),s=require("@stdlib/string-format"),v=C.get("dtypes.default"),E=C.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return ar(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,f,o,V,d;if(A(e))throw new TypeError(s("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=tr(r,d,V):i=j(r,d,V,e),f=[t],o=[a],d=nr(f,o),arguments.length>6?new h(e,i,f,o,d,u,l):new h(e,i,f,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):er(e)?(A(r)?n=R(e):F(r)?n=ir(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):rr(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):$(e)?(A(r)?(n=e[z](),n=_(n)):F(r)?(n=e[z](),n=M(_(n))):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(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(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,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(t)){if(!q(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),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(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,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(!q(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(s("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(s("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(s("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(s("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(s("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,g(u),u)}U.exports=ur});var W=D(function(hr,S){"use strict";var L=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,or=require("@stdlib/assert-is-iterable-like"),Y=require("@stdlib/assert-is-arraybuffer"),G=require("@stdlib/assert-is-collection"),sr=require("@stdlib/ndarray-base-assert-is-data-type"),fr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!sr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,f,o;if(u=fr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(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=c(u,f),o)throw o;return m(i,e,u)}if(Y(i)){if(L(f))return m(i,f,e,u);if(o=c(u,f),o)throw o;return m(i,e,u)}if(G(i)){if(o=c(u,f),o)throw o;return m(i,e,u)}if(o=c(u,f),o)throw o;return m(i,e,u)}if(i=arguments[0],L(i)||Y(i)||G(i)||or(i))return m(i,e,u);if(o=c(u,i),o)throw o;return m(e,u)}}S.exports=mr});var vr=require("@stdlib/utils-define-nonenumerable-read-only-property"),gr=W(),H=x();vr(H,"factory",gr);module.exports=H; -/** -* @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 8bece75..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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 Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 001fb71..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}}( 16 ); - > 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 6433bfa..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 objects... -{ - 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 objects... -{ - 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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 9733226..cc687c7 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..15f79ef --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(A(s)?(a=r[V](),a=x(a)):L(s)?(a=r[V](),a=c(x(a))):a=y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..199fcbb --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 6711e26..0000000 --- a/lib/index.js +++ /dev/null @@ -1,133 +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 Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // 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 1aed3f2..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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 ) { - 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 ); - } - // 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 ) ) { - if ( isGenericDataType( dtype ) ) { - buf = arg[ ITERATOR_SYMBOL ](); - buf = iterator2array( buf ); - } else if ( isBinaryDataType( dtype ) ) { - buf = arg[ ITERATOR_SYMBOL ](); - buf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length - } else { - buf = typedarray( arg, 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 2801e8d..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,78 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "github:stdlib-js/assert-is-ndarray-like-with-data-type#main", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..bf5d25b --- /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.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 a7f6829..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,1834 +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 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 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 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 an options argument which is not an object', 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 `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, 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(); -}); From b86a01b1d06d43f6651d29b00b8a3b5c88f7a617 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 23:57:31 +0000 Subject: [PATCH 09/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index 9fe2c8e..27b9e31 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 91f082b..1c91bb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 0ba704c45aa7eb361ddd78664ad97f1735dc1ac8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 23:57:54 +0000 Subject: [PATCH 10/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cc687c7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 15f79ef..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(A(s)?(a=r[V](),a=x(a)):L(s)?(a=r[V](),a=c(x(a))):a=y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index 199fcbb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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\tif ( isGenericDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = iterator2array( buf );\n\t\t} else if ( isBinaryDataType( dtype ) ) {\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tbuf = array2buffer( iterator2array( buf ) ); // note: the temporary array is necessary as we cannot allocate a `Buffer` in advance due to the iterator's indeterminate length\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( 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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index bf5d25b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a67f4e8a8abeb49122d67f3fb549ac2d0de70376 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 23:59:16 +0000 Subject: [PATCH 11/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 52 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 133 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - test/test.main.js | 3173 ------------ 49 files changed, 4889 insertions(+), 9139 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 418726a..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 001fb71..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}}( 16 ); - > 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 6433bfa..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 objects... -{ - 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 objects... -{ - 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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 9733226..cc687c7 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..4c1e41f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..c72f13e --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 6711e26..0000000 --- a/lib/index.js +++ /dev/null @@ -1,133 +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 Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // 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 27b9e31..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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 ) { - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 1c91bb7..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "github:stdlib-js/assert-is-ndarray-like-with-data-type#main", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..e97b387 --- /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.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 873d275..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 (byte offset)', 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 (byte offset, 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 (byte offset, 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 (byte offset, 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 (byte offset, 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 (byte offset, 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 (byte offset, 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 (byte offset, 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, byte offset)', 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, byte offset, 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, byte offset, 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, byte offset, 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(); -}); From 219008593025ea00f317b1cbe315ce6bf91e20db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 06:40:58 +0000 Subject: [PATCH 12/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index 9fe2c8e..27b9e31 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 91f082b..1c91bb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 9c82319b1bbd57a2be09ecfc8da882165edcf063 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 06:41:22 +0000 Subject: [PATCH 13/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cc687c7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c1e41f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index c72f13e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index e97b387..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b6436531ef3d99ce2824439bd8f3d4fb4333c814 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 06:42:31 +0000 Subject: [PATCH 14/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 53 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 133 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 10839 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 418726a..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Vector = require( '@stdlib/ndarray-vector-ctor' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 001fb71..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}}( 16 ); - > 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 6433bfa..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 objects... -{ - 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 objects... -{ - 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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 9733226..cc687c7 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..4c1e41f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..c72f13e --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 6711e26..0000000 --- a/lib/index.js +++ /dev/null @@ -1,133 +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 Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector(); -* // returns -* -* var len = v.length; -* // returns 0 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ] ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var v = new Vector( [ 1.0, 2.0 ], 'float32' ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float32' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf ); -* // returns -* -* var len = v.length; -* // returns 4 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 32 ); -* var v = new Vector( buf, 16 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // returns 'float64' -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Vector = require( '@stdlib/ndarray-vector-ctor' ); -* -* var buf = new ArrayBuffer( 64 ); -* var v = new Vector( buf, 16, 2 ); -* // returns -* -* var len = v.length; -* // returns 2 -* -* var dt = v.dtype; -* // 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 27b9e31..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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 ) { - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 1c91bb7..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "github:stdlib-js/assert-is-ndarray-like-with-data-type#main", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..e97b387 --- /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(); -}); From 93c643cc0496c17369f5ee0e379fbc7424b90196 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 09:02:48 +0000 Subject: [PATCH 15/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 91f082b..1c91bb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 6475a5b7154b176eab9be77ec96bfc2ccbbcb436 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 09:03:10 +0000 Subject: [PATCH 16/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cc687c7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a typed array - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c1e41f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index c72f13e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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 ) {\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 );\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 Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector();\n* // returns \n*\n* var len = v.length;\n* // returns 0\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var v = new Vector( [ 1.0, 2.0 ], 'float32' );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float32'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf );\n* // returns \n*\n* var len = v.length;\n* // returns 4\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 32 );\n* var v = new Vector( buf, 16 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\n* // returns 'float64'\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Vector from '@stdlib/ndarray-vector-ctor';\n*\n* var buf = new ArrayBuffer( 64 );\n* var v = new Vector( buf, 16, 2 );\n* // returns \n*\n* var len = v.length;\n* // returns 2\n*\n* var dt = v.dtype;\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index e97b387..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 38995d9d5ede420dd42f5a397f09bfee1cf37845 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 09:04:10 +0000 Subject: [PATCH 17/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 59 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 10859 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 001fb71..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}}( 16 ); - > 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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 0930fa8..2709636 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..4c1e41f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 1c91bb7..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "github:stdlib-js/assert-is-ndarray-like-with-data-type#main", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..99e848b --- /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(); -}); From 973db2b833cb25f68f052311e54fa7600cd69f0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 19:07:51 +0000 Subject: [PATCH 18/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 91f082b..1c91bb7 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.3.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 50ae3f9533c21cf7eb85ce75b178c88865a347a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 19:08:14 +0000 Subject: [PATCH 19/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2709636..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c1e41f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 99e848b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e88c13582aa12dd08291aade46b2c8cf48942498 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 May 2025 19:09:03 +0000 Subject: [PATCH 20/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 60 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 10860 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +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 status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ Copyright © 2016-2025. 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 0930fa8..2709636 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..4c1e41f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 1c91bb7..e160505 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.0", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.2.2", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.3.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "github:stdlib-js/assert-is-ndarray-like-with-data-type#main", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "github:stdlib-js/console-log-each-map#main", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..99e848b --- /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(); -}); From a9bc3198c994b6a4e38e93dd2bda816246f1f402 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:45:03 +0000 Subject: [PATCH 21/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 5f0b65b..1d5294d 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.2.2", "@stdlib/ndarray-defaults": "^0.4.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", From 03e5704f66bf7aa8a88261e86d86b02c0dc67cb2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:48:09 +0000 Subject: [PATCH 22/69] Remove files --- index.d.ts | 926 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5773 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 2709636..0000000 --- a/index.d.ts +++ /dev/null @@ -1,926 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4c1e41f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.0-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.3.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 99e848b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 569c61c53d85b69a7a5f37b8b4d9ab0c1e5e381b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:48:40 +0000 Subject: [PATCH 23/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 10968 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..39cbd2f --- /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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.0-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 1d5294d..3f68d63 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.3.0", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-defaults": "^0.4.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "^0.1.0", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "github:stdlib-js/blas-ext-sum#main", - "@stdlib/console-log-each-map": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.4.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..887f36a --- /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(); -}); From 6caaaae2b36017a60c3fcf1c88debce5c5af3fa2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:20:43 +0000 Subject: [PATCH 24/69] Update README.md for ESM bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fecb12..94e7f3e 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; ``` #### vector( \[dtype]\[, options] ) @@ -274,7 +274,7 @@ import unzip from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-unzip@esm/index.m import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import sum from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-sum@esm/index.mjs'; import logEachMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/console-log-each-map@esm/index.mjs'; -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; // Create an array of random array lengths: var lens = discreteUniform( 10, 5, 15, { From 08d03ba9a2955b9884d51075a536c593345185ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:20:44 +0000 Subject: [PATCH 25/69] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 94e7f3e..9367278 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-vector-ctor/tags). For example, + ```javascript import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0 You can also import the following named exports from the package: ```javascript -import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; +import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; ``` #### vector( \[dtype]\[, options] ) @@ -274,7 +279,7 @@ import unzip from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-unzip@esm/index.m import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import sum from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-sum@esm/index.mjs'; import logEachMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/console-log-each-map@esm/index.mjs'; -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.0-esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; // Create an array of random array lengths: var lens = discreteUniform( 10, 5, 15, { From cb950a71c37d594a674f70ebf3b6e841a7c34716 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 02:25:10 +0000 Subject: [PATCH 26/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index c75636c..e327564 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@stdlib/ndarray-ctor": "^0.3.0", "@stdlib/ndarray-defaults": "^0.4.0", "@stdlib/object-assign": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 08ad5569538788f9a7c80a33930df1c4c7d85c8d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 03:31:25 +0000 Subject: [PATCH 27/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 39cbd2f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.0-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 887f36a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 979c54f1bdf982c15fb9281e329cc385e7744fdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 03:32:02 +0000 Subject: [PATCH 28/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 10969 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9822b1f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-02T02:01:20.415Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..62de33a --- /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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.0-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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":";;k/EAqDA,SAASA,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,cACzBD,EAAKI,SAAWH,EAAQG,UAClBC,EAAWL,EAAKI,WACd,IAAIE,UAAWC,EAAQ,SAAU,WAAYP,EAAKI,WAGtDD,EAAYF,EAAS,UACzBD,EAAKQ,KAAOP,EAAQO,MACdC,EAAaT,EAAKQ,OAChB,IAAIF,UAAWC,EAAQ,wEAAyE,OAAQP,EAAKQ,OAGjHL,EAAYF,EAAS,WACzBD,EAAKU,MAAQT,EAAQS,OACfC,EAASX,EAAKU,QACZ,IAAIJ,UAAWC,EAAQ,qEAAsE,QAASP,EAAKU,QAG7G,KApBC,IAAIJ,UAAWC,EAAQ,SAAUN,GAqB1C,CC3BA,IAAIW,EAAgBC,EAASC,IAAK,kBAC9BC,EAAgBF,EAASC,IAAK,SAYlC,SAASE,EAAmBC,GAC3B,MAAmB,YAAVA,CACV,CASA,SAASC,EAAkBD,GAC1B,MAAmB,WAAVA,CACV,CASA,SAASE,EAAclB,GACtB,OAAKE,EAAYF,EAAS,SAClBA,EAAQS,MAETK,CACR,CA8DA,SAASK,EAAoBH,EAAOI,EAAQC,EAAQC,EAAQC,EAAYd,EAAOT,GAC9E,IAAIwB,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,EAAmBC,GACvB,MAAM,IAAIX,UAAWC,EAAQ,2FAA4FU,IAwB1H,OAtBAY,EAAIL,EAGJI,EAAIN,EAASC,EAGRA,EAAS,IAEbM,IADAD,IAAM,GACGE,EAAiBb,IAI1BQ,EADIP,EAAkBD,GAChBc,EAAoBV,EAAQQ,EAAGD,GAE/BI,EAAYX,EAAQQ,EAAGD,EAAGX,GAKjCY,EAAII,EAFJP,EAAK,CAAEJ,GACPK,EAAK,CAAEJ,IAIFW,UAAUZ,OAAS,EAChB,IAAIa,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAAOT,GAE5C,IAAIkC,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAC5C,CAiFA,SAAS0B,EAAiBC,EAAKpB,EAAOhB,GACrC,IAAID,EACAyB,EASJ,OALCzB,EADgB,OAAZC,EACG,CAAA,EAEAA,EAGHqC,EAAsBD,IAC1BZ,EAAMJ,EAAQJ,EAAOoB,GACd,IAAIF,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5EuC,EAAUF,IAEbZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvBwB,EAAYJ,GAEZL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E0C,EAAcL,IAEjBZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvB0B,EAAcN,GAEdL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E4C,EAAeP,GACZjB,EAAoBH,EAAOoB,EAAKA,EAAIQ,WAAWf,EAAiBb,GAAS,EAAG,EAAGE,EAAcnB,GAAQA,GAGxG8C,EAAgBT,IACpBZ,EAAMY,EAAKU,KACXtB,EAAMuB,EAAgBvB,GACjBP,EAAkBD,GACtBQ,EAAMkB,EAAclB,GACRT,EAAmBC,KAC/BQ,EAAMO,EAAYP,EAAKR,IAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAGhE,OAAZC,GAAoBgD,EAAeZ,IACvCZ,EAAMJ,EAAQJ,EAAO,GACd,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAckB,GAAOA,IAEzE,IACR,CAyHA,SAASa,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA/B,EACAgC,EAKJ,GAAe,KAHfN,EAAQjB,UAAUZ,QAKjB,OADAG,EAAMJ,EAAQT,EAAe,GACtB,IAAIuB,EAASvB,EAAea,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGP,GAKnE,GAHAqC,EAAOlB,UAAW,GAGH,IAAViB,EAAc,CAClB,GAAKO,EAAYN,GAChB,OAAOhB,EAAiB,EAAGgB,EAAM,MAGlC,GAAa,QADbK,EAAMrB,EAAiBgB,EAAMxC,EAAe,OAE3C,MAAM,IAAIN,UAAWC,EAAQ,6IAA8I6C,IAE5K,OAAOK,CACP,CAID,GAHAJ,EAAOnB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYN,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjB,EAAiB,EAAGgB,EAAMC,EACjC,CAED,GAAKK,EAAYL,GAAS,CAEzB,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMC,EAAM,OAElC,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,GAAKnB,EAAsBe,GAAS,CACnC,IAAMT,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,OAAOhC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMtC,EAClH,CAED,GAAc,OAATsC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMxC,EAAeyC,IAE3C,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAID,GAHAH,EAAOpB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYJ,GAAS,CACzB,IAAMV,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMtC,EAChG,CAED,GAAK2C,EAAYL,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAGxC,GAAa,QADbG,EAAMrB,EAAiBgB,EAAMC,EAAMC,IAElC,MAAM,IAAIhD,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,IAAMb,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAC1B,OAAOlC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMtC,GAGhE,GAAc,OAATuC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,OAAOlC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMlC,EAAcmC,GAAQA,EACxI,CAID,GAHAC,EAAOrB,UAAW,GAGH,IAAViB,EAAc,CAClB,IAAMP,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAAS,CACnC,GAAKI,EAAYH,GAChB,OAAOnC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMtC,GAGvD,IAAMkC,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMlC,EAAcoC,GAAQA,EACrF,CAED,IAAMG,EAAYJ,GACjB,MAAM,IAAIhD,UAAWC,EAAQ,0FAA2F+C,IAEzH,IAAML,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMlC,EAAcoC,GAAQA,EACtH,CAID,GAHAC,EAAOtB,UAAW,IAGZU,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,IAAMf,EAAsBgB,GAC3B,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,IAAMI,EAAYH,GACjB,MAAM,IAAIjD,UAAWC,EAAQ,2FAA4FgD,IAE1H,IAAMN,EAAeO,GACpB,MAAM,IAAIlD,UAAWC,EAAQ,SAAUiD,IAExC,OAAOpC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMlC,EAAcqC,GAAQA,EAC7E,CCzdA,SAASG,EAAS1C,EAAOhB,GACxB,IAAID,EACA4D,EACJ,IAAMF,EAAYzC,GACjB,MAAM,IAAIX,UAAWC,EAAQ,+EAAgFU,IAG9G,GADAjB,EAAO,CAAA,EACFkC,UAAUZ,OAAS,IACvBsC,EAAM7D,EAAUC,EAAMC,IAErB,MAAM2D,EAGR,OAgBA,WACC,IAAI3D,EACAkD,EACAC,EACAC,EACAO,EAMJ,GAJA3D,EAAU4D,EAAc,GAAI7D,GAC5BmD,EAAQjB,UAAUZ,OAGH,IAAV6B,EACJ,OAAOW,EAAM7C,EAAOhB,GAGrB,GAAKkD,EAAQ,EAAI,CAEhB,GADAS,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpE,CAED,GAAe,IAAVkD,EAAc,CAElB,GAAKb,EAAsBJ,UAAW,IACrC,OAAO4B,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,GAIrE,GADA2D,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpD,CAED,GAAe,IAAVkD,EAAc,CAKlB,GAHAE,EAAOnB,UAAW,GAGbI,EAJLc,EAAOlB,UAAW,IAIkB,CAEnC,GADA0B,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAK2C,EAAeQ,GAAS,CAE5B,GAAKd,EAAsBe,GAC1B,OAAOS,EAAMV,EAAMC,EAAMpC,EAAOhB,GAIjC,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAKyC,EAAcU,GAAS,CAE3B,GADAQ,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAGD,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAKD,GAHAmD,EAAOlB,UAAW,GAIjBI,EAAsBc,IACtBR,EAAeQ,IACfV,EAAcU,IACdN,EAAgBM,GAEhB,OAAOU,EAAMV,EAAMnC,EAAOhB,GAI3B,GADA2D,EAAM7D,EAAUE,EAASmD,GACpBQ,EACJ,MAAMA,EAEP,OAAOE,EAAM7C,EAAOhB,EACpB,CACF,CCpHA8D,EAAAD,EAAA,UAAAH"} \ No newline at end of file diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 e327564..3f68d63 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "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,80 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-from-iterator": "^0.2.2", - "@stdlib/array-typed": "^0.3.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-iterable-like": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/buffer-from-arraybuffer": "^0.2.2", - "@stdlib/buffer-from-buffer": "^0.2.2", - "@stdlib/ndarray-base-assert-is-data-type": "^0.3.0", - "@stdlib/ndarray-base-assert-is-index-mode": "^0.2.2", - "@stdlib/ndarray-base-assert-is-order": "^0.2.2", - "@stdlib/ndarray-base-buffer": "^0.3.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.3.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.3.0", - "@stdlib/ndarray-defaults": "^0.4.0", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-cartesian-product": "^0.2.2", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "^0.1.0", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "^0.1.0", - "@stdlib/console-log-each-map": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.4.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-unzip": "^0.2.2", - "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.2" - }, - "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..46cff61 --- /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(); -}); From 2eaf467606bca975e701a40099650427cc2a66c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:13:51 +0000 Subject: [PATCH 29/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index f81c25b..62110e1 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 576fc79dadee7ce4ac9e16304a31f08ba1a05e64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:06:09 +0000 Subject: [PATCH 30/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 62de33a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterable-like@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import s 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.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.0-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.2-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.0-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 46cff61..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6072682009367cfafeb3ee81ac5dfc2521d8a2d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:06:42 +0000 Subject: [PATCH 31/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 10971 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..58886c3 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 62110e1..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,80 +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-data-type": "^0.2.3", - "@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.0", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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.2", - "@stdlib/assert-is-ndarray-like-with-data-type": "^0.1.1", - "@stdlib/assert-is-same-array": "^0.2.2", - "@stdlib/assert-is-same-complex128array": "^0.2.2", - "@stdlib/assert-is-same-float32array": "^0.2.2", - "@stdlib/assert-is-same-float64array": "^0.2.2", - "@stdlib/blas-ext-sum": "^0.1.0", - "@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..45e4eaf --- /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(); -}); From 2f54addfe932a35f28ceeb472bb263762505e038 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:35:50 +0000 Subject: [PATCH 32/69] Update README.md for ESM bundle v0.1.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 24129fe..eb0e51b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ limitations under the License. ## Usage ```javascript -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; ``` #### vector( \[dtype]\[, options] ) @@ -274,7 +274,7 @@ import unzip from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-unzip@esm/index.m import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import sum from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-sum@esm/index.mjs'; import logEachMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/console-log-each-map@esm/index.mjs'; -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; // Create an array of random array lengths: var lens = discreteUniform( 10, 5, 15, { From c4bc9668cf69c842f2be369e8f8b52f338c28586 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:35:51 +0000 Subject: [PATCH 33/69] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eb0e51b..9745c26 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-vector-ctor/tags). For example, + ```javascript import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; ``` @@ -58,7 +63,7 @@ import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0 You can also import the following named exports from the package: ```javascript -import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; +import { factory } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; ``` #### vector( \[dtype]\[, options] ) @@ -274,7 +279,7 @@ import unzip from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-unzip@esm/index.m import dtypes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs'; import sum from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-sum@esm/index.mjs'; import logEachMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/console-log-each-map@esm/index.mjs'; -import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@v0.1.1-esm/index.mjs'; +import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs'; // Create an array of random array lengths: var lens = discreteUniform( 10, 5, 15, { From 8703419327fe07f1eb820622e8f777d0e5dfae5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:57:21 +0000 Subject: [PATCH 34/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 98f030a50f1118cd9756214985c9ac2765086eff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 02:48:03 +0000 Subject: [PATCH 35/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 58886c3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.0-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 45e4eaf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4ea554a767503aedcc599f0effebb1eae20c10a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 02:48:50 +0000 Subject: [PATCH 36/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 10972 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index adbca07..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T01:40:29.723Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 1f18e278e03b336b4593caa05f595958f34eee26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:10:50 +0000 Subject: [PATCH 37/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From ace86197f39917c35e3b83d1655f8cc5e2419777 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 04:56:32 +0000 Subject: [PATCH 38/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0293d25c59d2fa68f839054d09890d3529b49365 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 04:57:11 +0000 Subject: [PATCH 39/69] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 10972 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +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 - -# 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 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +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 diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 970b9b6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T02:20:49.661Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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":";;k/EAqDA,SAASA,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,cACzBD,EAAKI,SAAWH,EAAQG,UAClBC,EAAWL,EAAKI,WACd,IAAIE,UAAWC,EAAQ,SAAU,WAAYP,EAAKI,WAGtDD,EAAYF,EAAS,UACzBD,EAAKQ,KAAOP,EAAQO,MACdC,EAAaT,EAAKQ,OAChB,IAAIF,UAAWC,EAAQ,wEAAyE,OAAQP,EAAKQ,OAGjHL,EAAYF,EAAS,WACzBD,EAAKU,MAAQT,EAAQS,OACfC,EAASX,EAAKU,QACZ,IAAIJ,UAAWC,EAAQ,qEAAsE,QAASP,EAAKU,QAG7G,KApBC,IAAIJ,UAAWC,EAAQ,SAAUN,GAqB1C,CC3BA,IAAIW,EAAgBC,EAASC,IAAK,kBAC9BC,EAAgBF,EAASC,IAAK,SAYlC,SAASE,EAAmBC,GAC3B,MAAmB,YAAVA,CACV,CASA,SAASC,EAAkBD,GAC1B,MAAmB,WAAVA,CACV,CASA,SAASE,EAAclB,GACtB,OAAKE,EAAYF,EAAS,SAClBA,EAAQS,MAETK,CACR,CA8DA,SAASK,EAAoBH,EAAOI,EAAQC,EAAQC,EAAQC,EAAYd,EAAOT,GAC9E,IAAIwB,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,EAAmBC,GACvB,MAAM,IAAIX,UAAWC,EAAQ,2FAA4FU,IAwB1H,OAtBAY,EAAIL,EAGJI,EAAIN,EAASC,EAGRA,EAAS,IAEbM,IADAD,IAAM,GACGE,EAAiBb,IAI1BQ,EADIP,EAAkBD,GAChBc,EAAoBV,EAAQQ,EAAGD,GAE/BI,EAAYX,EAAQQ,EAAGD,EAAGX,GAKjCY,EAAII,EAFJP,EAAK,CAAEJ,GACPK,EAAK,CAAEJ,IAIFW,UAAUZ,OAAS,EAChB,IAAIa,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAAOT,GAE5C,IAAIkC,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAC5C,CAiFA,SAAS0B,EAAiBC,EAAKpB,EAAOhB,GACrC,IAAID,EACAyB,EASJ,OALCzB,EADgB,OAAZC,EACG,CAAA,EAEAA,EAGHqC,EAAsBD,IAC1BZ,EAAMJ,EAAQJ,EAAOoB,GACd,IAAIF,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5EuC,EAAUF,IAEbZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvBwB,EAAYJ,GAEZL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E0C,EAAcL,IAEjBZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvB0B,EAAcN,GAEdL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E4C,EAAeP,GACZjB,EAAoBH,EAAOoB,EAAKA,EAAIQ,WAAWf,EAAiBb,GAAS,EAAG,EAAGE,EAAcnB,GAAQA,GAGxG8C,EAAgBT,IACpBZ,EAAMY,EAAKU,KACXtB,EAAMuB,EAAgBvB,GACjBP,EAAkBD,GACtBQ,EAAMkB,EAAclB,GACRT,EAAmBC,KAC/BQ,EAAMO,EAAYP,EAAKR,IAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAGhE,OAAZC,GAAoBgD,EAAeZ,IACvCZ,EAAMJ,EAAQJ,EAAO,GACd,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAckB,GAAOA,IAEzE,IACR,CAyHA,SAASa,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA/B,EACAgC,EAKJ,GAAe,KAHfN,EAAQjB,UAAUZ,QAKjB,OADAG,EAAMJ,EAAQT,EAAe,GACtB,IAAIuB,EAASvB,EAAea,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGP,GAKnE,GAHAqC,EAAOlB,UAAW,GAGH,IAAViB,EAAc,CAClB,GAAKO,EAAYN,GAChB,OAAOhB,EAAiB,EAAGgB,EAAM,MAGlC,GAAa,QADbK,EAAMrB,EAAiBgB,EAAMxC,EAAe,OAE3C,MAAM,IAAIN,UAAWC,EAAQ,6IAA8I6C,IAE5K,OAAOK,CACP,CAID,GAHAJ,EAAOnB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYN,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjB,EAAiB,EAAGgB,EAAMC,EACjC,CAED,GAAKK,EAAYL,GAAS,CAEzB,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMC,EAAM,OAElC,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,GAAKnB,EAAsBe,GAAS,CACnC,IAAMT,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,OAAOhC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMtC,EAClH,CAED,GAAc,OAATsC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMxC,EAAeyC,IAE3C,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAID,GAHAH,EAAOpB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYJ,GAAS,CACzB,IAAMV,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMtC,EAChG,CAED,GAAK2C,EAAYL,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAGxC,GAAa,QADbG,EAAMrB,EAAiBgB,EAAMC,EAAMC,IAElC,MAAM,IAAIhD,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,IAAMb,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAC1B,OAAOlC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMtC,GAGhE,GAAc,OAATuC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,OAAOlC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMlC,EAAcmC,GAAQA,EACxI,CAID,GAHAC,EAAOrB,UAAW,GAGH,IAAViB,EAAc,CAClB,IAAMP,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAAS,CACnC,GAAKI,EAAYH,GAChB,OAAOnC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMtC,GAGvD,IAAMkC,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMlC,EAAcoC,GAAQA,EACrF,CAED,IAAMG,EAAYJ,GACjB,MAAM,IAAIhD,UAAWC,EAAQ,0FAA2F+C,IAEzH,IAAML,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMlC,EAAcoC,GAAQA,EACtH,CAID,GAHAC,EAAOtB,UAAW,IAGZU,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,IAAMf,EAAsBgB,GAC3B,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,IAAMI,EAAYH,GACjB,MAAM,IAAIjD,UAAWC,EAAQ,2FAA4FgD,IAE1H,IAAMN,EAAeO,GACpB,MAAM,IAAIlD,UAAWC,EAAQ,SAAUiD,IAExC,OAAOpC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMlC,EAAcqC,GAAQA,EAC7E,CCzdA,SAASG,EAAS1C,EAAOhB,GACxB,IAAID,EACA4D,EACJ,IAAMF,EAAYzC,GACjB,MAAM,IAAIX,UAAWC,EAAQ,+EAAgFU,IAG9G,GADAjB,EAAO,CAAA,EACFkC,UAAUZ,OAAS,IACvBsC,EAAM7D,EAAUC,EAAMC,IAErB,MAAM2D,EAGR,OAgBA,WACC,IAAI3D,EACAkD,EACAC,EACAC,EACAO,EAMJ,GAJA3D,EAAU4D,EAAc,GAAI7D,GAC5BmD,EAAQjB,UAAUZ,OAGH,IAAV6B,EACJ,OAAOW,EAAM7C,EAAOhB,GAGrB,GAAKkD,EAAQ,EAAI,CAEhB,GADAS,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpE,CAED,GAAe,IAAVkD,EAAc,CAElB,GAAKb,EAAsBJ,UAAW,IACrC,OAAO4B,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,GAIrE,GADA2D,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpD,CAED,GAAe,IAAVkD,EAAc,CAKlB,GAHAE,EAAOnB,UAAW,GAGbI,EAJLc,EAAOlB,UAAW,IAIkB,CAEnC,GADA0B,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAK2C,EAAeQ,GAAS,CAE5B,GAAKd,EAAsBe,GAC1B,OAAOS,EAAMV,EAAMC,EAAMpC,EAAOhB,GAIjC,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAKyC,EAAcU,GAAS,CAE3B,GADAQ,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAGD,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAKD,GAHAmD,EAAOlB,UAAW,GAIjBI,EAAsBc,IACtBR,EAAeQ,IACfV,EAAcU,IACdN,EAAgBM,GAEhB,OAAOU,EAAMV,EAAMnC,EAAOhB,GAI3B,GADA2D,EAAM7D,EAAUE,EAASmD,GACpBQ,EACJ,MAAMA,EAEP,OAAOE,EAAM7C,EAAOhB,EACpB,CACF,CCpHA8D,EAAAD,EAAA,UAAAH"} \ No newline at end of file diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 09eb35668b531c7782b21ac0ef4ca691550ec6cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 02:42:22 +0000 Subject: [PATCH 40/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 4e33cb4bf33bc2edb0e05b27db6f99c4edfd1e05 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 04:21:23 +0000 Subject: [PATCH 41/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9766b20ada8e26e85e906f5e9f12de294009044a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 04:22:12 +0000 Subject: [PATCH 42/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 317 -- benchmark/benchmark.factory.size.js | 106 - benchmark/benchmark.js | 263 - benchmark/benchmark.size.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 10983 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 7d6a1d4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-23T02:07:51.065Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 641e808..0000000 --- a/benchmark/benchmark.factory.js +++ /dev/null @@ -1,317 +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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// MAIN // - -bench( pkg+':factory', 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( pkg+':factory:dtype=float64', 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( pkg+':factory:dtype=float32', 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( pkg+':factory:dtype=complex128', 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( pkg+':factory:dtype=complex64', 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( pkg+':factory:dtype=int32', 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( pkg+':factory:dtype=uint32', 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( pkg+':factory:dtype=int16', 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( pkg+':factory:dtype=uint16', 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( pkg+':factory:dtype=int8', 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( pkg+':factory:dtype=uint8', 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( pkg+':factory:dtype=uint8c', 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( pkg+':factory:dtype=generic', 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 b4b55f1..0000000 --- a/benchmark/benchmark.factory.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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ).factory; - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':factory:dtype='+dt+',size='+len, f ); - } - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index dd49281..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,263 +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 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( pkg+':dtype=float64', 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( pkg+':dtype=float32', 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( pkg+':dtype=complex128', 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( pkg+':dtype=complex64', 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( pkg+':dtype=int32', 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( pkg+':dtype=uint32', 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( pkg+':dtype=int16', 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( pkg+':dtype=uint16', 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( pkg+':dtype=int8', 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( pkg+':dtype=uint8', 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( pkg+':dtype=uint8c', 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( pkg+':dtype=generic', 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 bed45b7..0000000 --- a/benchmark/benchmark.size.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var vector = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// 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( pkg+':dtype='+dt+',size='+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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 0c8c2089c6bb59c9b9e3f42f977ec43b398d7464 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 07:34:24 +0000 Subject: [PATCH 43/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 28a1f8f8d9a315fe3b3899433de478a1357ff552 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 07:35:49 +0000 Subject: [PATCH 44/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd1bc99eaab59bc29dcf4ae8d93b6e1f559b6651 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 07:36:29 +0000 Subject: [PATCH 45/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 107 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4889 insertions(+), 11020 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 5854e6f5c61fc297e860433ddbeb18d1a0fed6f5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:46:41 +0000 Subject: [PATCH 46/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 93e7a8f7cfd518ba84849d664575031a77aaed0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:57:00 +0000 Subject: [PATCH 47/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9bd80b4b88a40745ff82cbd12d53c75709ff9226 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:57:36 +0000 Subject: [PATCH 48/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 107 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 11021 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 7e0449e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-09T03:35:35.486Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From a9f44f53ec2f068ad3454f14563100d855ae2f55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:18:11 +0000 Subject: [PATCH 49/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From ac2b20aa72caac3aa471b419499875649578a33b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:19:05 +0000 Subject: [PATCH 50/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From dd86f00477234af0cad6ac5255743b81428fe250 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:19:45 +0000 Subject: [PATCH 51/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 107 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 81 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4889 insertions(+), 11021 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 8dde016..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-10T03:16:56.189Z 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 + + ```
@@ -336,7 +333,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]. @@ -399,11 +396,11 @@ 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
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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAc,QAAS,2CAA4C,EACnEC,EAAU,QAAS,sCAAuC,EAC1DC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACN,EAAWK,EAAK,QAAS,GACvB,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAGvHN,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACL,EAAaI,EAAK,IAAK,GACrB,IAAI,UAAWF,EAAQ,wEAAyE,OAAQE,EAAK,IAAK,CAAE,EAGxHN,EAAYO,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACJ,EAASG,EAAK,KAAM,GAClB,IAAI,UAAWF,EAAQ,qEAAsE,QAASE,EAAK,KAAM,CAAE,EAGrH,KApBC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAqBhH,CAKAT,EAAO,QAAUO,ICjFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAe,QAAS,8BAA+B,EACvDC,EAAgB,QAAS,+BAAgC,EACzDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAW,QAAS,0BAA2B,EAC/CC,EAAa,QAAS,0CAA2C,EACjEC,GAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,6BAA8B,EAChDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAO,QAAS,yBAA0B,EAC1CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,GAAiB,QAAS,qCAAsC,EAChEC,GAAqB,QAAS,iCAAkC,EAChEC,EAAe,QAAS,2BAA4B,EACpDC,GAAa,QAAS,4BAA6B,EACnDC,GAAiB,QAAS,6BAA8B,EACxDC,EAAkB,QAAS,wCAAyC,EACpEC,GAAkB,QAAS,yBAA0B,EACrDC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBT,EAAS,IAAK,gBAAiB,EAC/CU,EAAgBV,EAAS,IAAK,OAAQ,EAY1C,SAASW,EAAmBC,EAAQ,CACnC,OAASA,IAAU,SACpB,CASA,SAASC,EAAkBD,EAAQ,CAClC,OAASA,IAAU,QACpB,CASA,SAASE,EAAcC,EAAU,CAChC,OAAKpB,GAAYoB,EAAS,OAAQ,EAC1BA,EAAQ,MAETL,CACR,CA8DA,SAASM,EAAoBJ,EAAOhB,EAAQqB,EAAQC,EAAQC,EAAYC,EAAOL,EAAU,CACxF,IAAIM,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKd,EAAmBC,CAAM,EAC7B,MAAM,IAAI,UAAWJ,EAAQ,2FAA4FI,CAAM,CAAE,EAwBlI,OAtBAa,EAAIN,EAGJK,EAAIP,EAASC,EAGRA,EAAS,IACbM,GAAK,GACLC,GAAKD,EAAIlB,EAAiBM,CAAM,GAG5BC,EAAkBD,CAAM,EAC5BS,EAAMnB,GAAoBN,EAAQ6B,EAAGD,CAAE,EAEvCH,EAAMxB,EAAYD,EAAQ6B,EAAGD,EAAGZ,CAAM,EAGvCU,EAAK,CAAEL,CAAO,EACdM,EAAK,CAAEL,CAAO,EACdO,EAAIxB,GAAgBqB,EAAIC,CAAG,EAGtB,UAAU,OAAS,EAChB,IAAIxB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,EAAOL,CAAQ,EAEpD,IAAIhB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,CAAM,CAClD,CAiFA,SAASM,EAAiBC,EAAKf,EAAOG,EAAU,CAC/C,IAAIa,EACAP,EASJ,OANKN,IAAY,KAChBa,EAAO,CAAC,EAERA,EAAOb,EAGH3B,EAAsBuC,CAAI,GAC9BN,EAAMzB,EAAQgB,EAAOe,CAAI,EAClB,IAAI5B,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFnC,EAAUkC,CAAI,GACbhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMjB,GAAYuB,CAAI,EAEtBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFtC,EAAcqC,CAAI,GACjBhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMlB,EAAcwB,CAAI,EAExBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFrC,EAAeoC,CAAI,EAChBX,EAAoBJ,EAAOe,EAAKA,EAAI,WAAWrB,EAAiBM,CAAM,EAAG,EAAG,EAAGE,EAAcc,CAAK,EAAGA,CAAK,EAG7GvC,EAAgBsC,CAAI,GACxBN,EAAMM,EAAKpB,EAAgB,EAAE,EAC7Bc,EAAMhB,GAAgBgB,CAAI,EACrBR,EAAkBD,CAAM,EAC5BS,EAAMlB,EAAckB,CAAI,EACZV,EAAmBC,CAAM,IACrCS,EAAMxB,EAAYwB,EAAKT,CAAM,GAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFb,IAAY,MAAQvB,EAAemC,CAAI,GAC3CN,EAAMzB,EAAQgB,EAAO,CAAE,EAChB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAca,CAAI,EAAGA,CAAI,GAE7E,IACR,CAyHA,SAASE,IAAS,CACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAd,EACAe,EAKJ,GAHAN,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAT,EAAMzB,EAAQa,EAAe,CAAE,EACxB,IAAIV,EAASU,EAAeY,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGX,CAAc,EAKjF,GAHAqB,EAAO,UAAW,CAAE,EAGfD,IAAU,EAAI,CAClB,GAAKpC,EAAYqC,CAAK,EACrB,OAAOL,EAAiB,EAAGK,EAAM,IAAK,EAGvC,GADAK,EAAMV,EAAiBK,EAAMtB,EAAe,IAAK,EAC5C2B,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,6IAA8IuB,CAAK,CAAE,EAEnL,OAAOK,CACR,CAIA,GAHAJ,EAAO,UAAW,CAAE,EAGfF,IAAU,EAAI,CAElB,GAAKpC,EAAYqC,CAAK,EAAI,CACzB,GAAKC,IAAS,KACb,MAAM,IAAI,UAAWxB,EAAQ,qEAAsEwB,CAAK,CAAE,EAE3G,OAAON,EAAiB,EAAGK,EAAMC,CAAK,CACvC,CAEA,GAAKtC,EAAYsC,CAAK,EAAI,CAEzB,GADAI,EAAMV,EAAiBK,EAAMC,EAAM,IAAK,EACnCI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAKhD,EAAsB4C,CAAK,EAAI,CACnC,GAAK,CAACzC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,OAAOf,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMtB,CAAc,CACjI,CAEA,GAAKsB,IAAS,KACb,MAAM,IAAI,UAAWxB,EAAQ,qEAAsEwB,CAAK,CAAE,EAG3G,GADAI,EAAMV,EAAiBK,EAAMtB,EAAeuB,CAAK,EAC5CI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAIA,GAHAH,EAAO,UAAW,CAAE,EAGfH,IAAU,EAAI,CAElB,GAAKpC,EAAYuC,CAAK,EAAI,CACzB,GAAK,CAAC1C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,OAAOhB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMtB,CAAc,CAC/G,CAEA,GAAKhB,EAAYsC,CAAK,EAAI,CACzB,GAAKC,IAAS,KACb,MAAM,IAAI,UAAWzB,EAAQ,qEAAsEyB,CAAK,CAAE,EAG3G,GADAG,EAAMV,EAAiBK,EAAMC,EAAMC,CAAK,EACnCG,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAK,CAAC7C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAK5C,EAAsB6C,CAAK,EAC/B,OAAOjB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMtB,CAAc,EAG9E,GAAKuB,IAAS,KACb,MAAM,IAAI,UAAWzB,EAAQ,qEAAsEyB,CAAK,CAAE,EAE3G,OAAOjB,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMlB,EAAcmB,CAAK,EAAGA,CAAK,CAC9I,CAIA,GAHAC,EAAO,UAAW,CAAE,EAGfJ,IAAU,EAAI,CAClB,GAAK,CAACvC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAK5C,EAAsB6C,CAAK,EAAI,CACnC,GAAKvC,EAAYwC,CAAK,EACrB,OAAOlB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMtB,CAAc,EAGrE,GAAK,CAAClB,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC3F,CAEA,GAAK,CAACxC,EAAYuC,CAAK,EACtB,MAAM,IAAI,UAAWzB,EAAQ,0FAA2FyB,CAAK,CAAE,EAEhI,GAAK,CAACzC,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC5H,CAIA,GAHAC,EAAO,UAAW,CAAE,EAGf,CAAC5C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,GAAK,CAAC5C,EAAsB6C,CAAK,EAChC,MAAM,IAAI,UAAWzB,EAAQ,uEAAwEyB,CAAK,CAAE,EAE7G,GAAK,CAACvC,EAAYwC,CAAK,EACtB,MAAM,IAAI,UAAW1B,EAAQ,2FAA4F0B,CAAK,CAAE,EAEjI,GAAK,CAAC1C,EAAe2C,CAAK,EACzB,MAAM,IAAI,UAAW3B,EAAQ,qEAAsE2B,CAAK,CAAE,EAE3G,OAAOnB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMlB,EAAcqB,CAAK,EAAGA,CAAK,CAClF,CAKAhD,EAAO,QAAU0C,KCjmBjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,GAAiB,QAAS,iCAAkC,EAC5DC,EAAgB,QAAS,+BAAgC,EACzDC,EAAe,QAAS,8BAA+B,EACvDC,GAAa,QAAS,0CAA2C,EACjEC,GAAe,QAAS,uBAAwB,EAChDC,GAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAO,IAmGX,SAASC,GAASC,EAAOC,EAAU,CAClC,IAAIC,EACAC,EACJ,GAAK,CAACT,GAAYM,CAAM,EACvB,MAAM,IAAI,UAAWJ,GAAQ,+EAAgFI,CAAM,CAAE,EAGtH,GADAE,EAAO,CAAC,EACH,UAAU,OAAS,IACvBC,EAAMN,EAAUK,EAAMD,CAAQ,EACzBE,GACJ,MAAMA,EAGR,OAAOC,EAgBP,SAASA,GAAS,CACjB,IAAIH,EACAI,EACAC,EACAC,EACAJ,EAMJ,GAJAF,EAAUN,GAAc,CAAC,EAAGO,CAAK,EACjCG,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAOP,EAAME,EAAOC,CAAQ,EAG7B,GAAKI,EAAQ,EAAI,CAEhB,GADAF,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7E,CAEA,GAAKI,IAAU,EAAI,CAElB,GAAKf,EAAsB,UAAW,CAAE,CAAE,EACzC,OAAOQ,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,EAI7E,GADAE,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7D,CAEA,GAAKI,IAAU,EAAI,CAKlB,GAJAC,EAAO,UAAW,CAAE,EACpBC,EAAO,UAAW,CAAE,EAGfjB,EAAsBgB,CAAK,EAAI,CAEnC,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKT,EAAec,CAAK,EAAI,CAE5B,GAAKhB,EAAsBiB,CAAK,EAC/B,OAAOT,EAAMQ,EAAMC,EAAMP,EAAOC,CAAQ,EAIzC,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKR,EAAca,CAAK,EAAI,CAE3B,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAGA,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAKA,GAHAK,EAAO,UAAW,CAAE,EAInBhB,EAAsBgB,CAAK,GAC3Bd,EAAec,CAAK,GACpBb,EAAca,CAAK,GACnBf,GAAgBe,CAAK,EAErB,OAAOR,EAAMQ,EAAMN,EAAOC,CAAQ,EAInC,GADAE,EAAMN,EAAUI,EAASK,CAAK,EACzBH,EACJ,MAAMA,EAEP,OAAOL,EAAME,EAAOC,CAAQ,CAC7B,CACD,CAKAZ,EAAO,QAAUU,KChIjB,IAAIS,GAAc,QAAS,uDAAwD,EAC/EC,GAAU,IACVC,EAAO,IAKXF,GAAaE,EAAM,UAAWD,EAAQ,EAKtC,OAAO,QAAUC", - "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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From c21a50a3d44b607da22cc2b044da55274927311e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Apr 2026 04:00:28 +0000 Subject: [PATCH 52/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 06bda81fa65880483be5d9a723b0a2c33f35d955 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Apr 2026 04:07:29 +0000 Subject: [PATCH 53/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 71bc17256981a29c544235696f1b52af1ebb5207 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Apr 2026 04:08:04 +0000 Subject: [PATCH 54/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4893 insertions(+), 11030 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 c0540ac..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 real-valued data types: -var dts = dtypes( 'real_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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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":";;k/EAqDA,SAASA,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,cACzBD,EAAKI,SAAWH,EAAQG,UAClBC,EAAWL,EAAKI,WACd,IAAIE,UAAWC,EAAQ,SAAU,WAAYP,EAAKI,WAGtDD,EAAYF,EAAS,UACzBD,EAAKQ,KAAOP,EAAQO,MACdC,EAAaT,EAAKQ,OAChB,IAAIF,UAAWC,EAAQ,wEAAyE,OAAQP,EAAKQ,OAGjHL,EAAYF,EAAS,WACzBD,EAAKU,MAAQT,EAAQS,OACfC,EAASX,EAAKU,QACZ,IAAIJ,UAAWC,EAAQ,qEAAsE,QAASP,EAAKU,QAG7G,KApBC,IAAIJ,UAAWC,EAAQ,SAAUN,GAqB1C,CC3BA,IAAIW,EAAgBC,EAASC,IAAK,kBAC9BC,EAAgBF,EAASC,IAAK,SAYlC,SAASE,EAAmBC,GAC3B,MAAmB,YAAVA,CACV,CASA,SAASC,EAAkBD,GAC1B,MAAmB,WAAVA,CACV,CASA,SAASE,EAAclB,GACtB,OAAKE,EAAYF,EAAS,SAClBA,EAAQS,MAETK,CACR,CA8DA,SAASK,EAAoBH,EAAOI,EAAQC,EAAQC,EAAQC,EAAYd,EAAOT,GAC9E,IAAIwB,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKb,EAAmBC,GACvB,MAAM,IAAIX,UAAWC,EAAQ,2FAA4FU,IAwB1H,OAtBAY,EAAIL,EAGJI,EAAIN,EAASC,EAGRA,EAAS,IAEbM,IADAD,IAAM,GACGE,EAAiBb,IAI1BQ,EADIP,EAAkBD,GAChBc,EAAoBV,EAAQQ,EAAGD,GAE/BI,EAAYX,EAAQQ,EAAGD,EAAGX,GAKjCY,EAAII,EAFJP,EAAK,CAAEJ,GACPK,EAAK,CAAEJ,IAIFW,UAAUZ,OAAS,EAChB,IAAIa,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAAOT,GAE5C,IAAIkC,EAASlB,EAAOQ,EAAKC,EAAIC,EAAIE,EAAGnB,EAC5C,CAiFA,SAAS0B,EAAiBC,EAAKpB,EAAOhB,GACrC,IAAID,EACAyB,EASJ,OALCzB,EADgB,OAAZC,EACG,CAAA,EAEAA,EAGHqC,EAAsBD,IAC1BZ,EAAMJ,EAAQJ,EAAOoB,GACd,IAAIF,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5EuC,EAAUF,IAEbZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvBwB,EAAYJ,GAEZL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E0C,EAAcL,IAEjBZ,EADIT,EAAmBC,GACjBuB,EAAMH,GACDnB,EAAkBD,GACvB0B,EAAcN,GAEdL,EAAYK,EAAKpB,GAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAG5E4C,EAAeP,GACZjB,EAAoBH,EAAOoB,EAAKA,EAAIQ,WAAWf,EAAiBb,GAAS,EAAG,EAAGE,EAAcnB,GAAQA,GAGxG8C,EAAgBT,IACpBZ,EAAMY,EAAKU,KACXtB,EAAMuB,EAAgBvB,GACjBP,EAAkBD,GACtBQ,EAAMkB,EAAclB,GACRT,EAAmBC,KAC/BQ,EAAMO,EAAYP,EAAKR,IAEjB,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAcnB,GAAQA,IAGhE,OAAZC,GAAoBgD,EAAeZ,IACvCZ,EAAMJ,EAAQJ,EAAO,GACd,IAAIkB,EAASlB,EAAOQ,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGH,EAAckB,GAAOA,IAEzE,IACR,CAyHA,SAASa,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA/B,EACAgC,EAKJ,GAAe,KAHfN,EAAQjB,UAAUZ,QAKjB,OADAG,EAAMJ,EAAQT,EAAe,GACtB,IAAIuB,EAASvB,EAAea,EAAK,CAAEA,EAAIH,QAAU,CAAE,GAAK,EAAGP,GAKnE,GAHAqC,EAAOlB,UAAW,GAGH,IAAViB,EAAc,CAClB,GAAKO,EAAYN,GAChB,OAAOhB,EAAiB,EAAGgB,EAAM,MAGlC,GAAa,QADbK,EAAMrB,EAAiBgB,EAAMxC,EAAe,OAE3C,MAAM,IAAIN,UAAWC,EAAQ,6IAA8I6C,IAE5K,OAAOK,CACP,CAID,GAHAJ,EAAOnB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYN,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjB,EAAiB,EAAGgB,EAAMC,EACjC,CAED,GAAKK,EAAYL,GAAS,CAEzB,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMC,EAAM,OAElC,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,GAAKnB,EAAsBe,GAAS,CACnC,IAAMT,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,OAAOhC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMtC,EAClH,CAED,GAAc,OAATsC,EACJ,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAa,QADbI,EAAMrB,EAAiBgB,EAAMxC,EAAeyC,IAE3C,MAAM,IAAI/C,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAID,GAHAH,EAAOpB,UAAW,GAGH,IAAViB,EAAc,CAElB,GAAKO,EAAYJ,GAAS,CACzB,IAAMV,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,OAAOjC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMtC,EAChG,CAED,GAAK2C,EAAYL,GAAS,CACzB,GAAc,OAATC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAGxC,GAAa,QADbG,EAAMrB,EAAiBgB,EAAMC,EAAMC,IAElC,MAAM,IAAIhD,UAAWC,EAAQ,4HAA6H6C,IAE3J,OAAOK,CACP,CAED,IAAMb,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAC1B,OAAOlC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMtC,GAGhE,GAAc,OAATuC,EACJ,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,OAAOlC,EAAoBR,EAAewC,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBlB,GAAiB,EAAGyC,EAAMlC,EAAcmC,GAAQA,EACxI,CAID,GAHAC,EAAOrB,UAAW,GAGH,IAAViB,EAAc,CAClB,IAAMP,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAGxC,GAAKf,EAAsBgB,GAAS,CACnC,GAAKI,EAAYH,GAChB,OAAOnC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMtC,GAGvD,IAAMkC,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBR,EAAewC,EAAME,EAAM,EAAGD,EAAMlC,EAAcoC,GAAQA,EACrF,CAED,IAAMG,EAAYJ,GACjB,MAAM,IAAIhD,UAAWC,EAAQ,0FAA2F+C,IAEzH,IAAML,EAAeM,GACpB,MAAM,IAAIjD,UAAWC,EAAQ,SAAUgD,IAExC,OAAOnC,EAAoBkC,EAAMF,GAAOA,EAAKP,WAAWQ,GAAMvB,EAAiBwB,GAAQ,EAAGD,EAAMlC,EAAcoC,GAAQA,EACtH,CAID,GAHAC,EAAOtB,UAAW,IAGZU,EAAeQ,GACpB,MAAM,IAAI9C,UAAWC,EAAQ,SAAU6C,IAExC,IAAMd,EAAsBe,GAC3B,MAAM,IAAI/C,UAAWC,EAAQ,SAAU8C,IAExC,IAAMf,EAAsBgB,GAC3B,MAAM,IAAIhD,UAAWC,EAAQ,SAAU+C,IAExC,IAAMI,EAAYH,GACjB,MAAM,IAAIjD,UAAWC,EAAQ,2FAA4FgD,IAE1H,IAAMN,EAAeO,GACpB,MAAM,IAAIlD,UAAWC,EAAQ,SAAUiD,IAExC,OAAOpC,EAAoBmC,EAAMH,EAAME,EAAM,EAAGD,EAAMlC,EAAcqC,GAAQA,EAC7E,CCzdA,SAASG,EAAS1C,EAAOhB,GACxB,IAAID,EACA4D,EACJ,IAAMF,EAAYzC,GACjB,MAAM,IAAIX,UAAWC,EAAQ,+EAAgFU,IAG9G,GADAjB,EAAO,CAAA,EACFkC,UAAUZ,OAAS,IACvBsC,EAAM7D,EAAUC,EAAMC,IAErB,MAAM2D,EAGR,OAgBA,WACC,IAAI3D,EACAkD,EACAC,EACAC,EACAO,EAMJ,GAJA3D,EAAU4D,EAAc,GAAI7D,GAC5BmD,EAAQjB,UAAUZ,OAGH,IAAV6B,EACJ,OAAOW,EAAM7C,EAAOhB,GAGrB,GAAKkD,EAAQ,EAAI,CAEhB,GADAS,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpE,CAED,GAAe,IAAVkD,EAAc,CAElB,GAAKb,EAAsBJ,UAAW,IACrC,OAAO4B,EAAM5B,UAAW,GAAKA,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,GAIrE,GADA2D,EAAM7D,EAAUE,EAASiC,UAAW,IAEnC,MAAM0B,EAEP,OAAOE,EAAM5B,UAAW,GAAKA,UAAW,GAAKjB,EAAOhB,EACpD,CAED,GAAe,IAAVkD,EAAc,CAKlB,GAHAE,EAAOnB,UAAW,GAGbI,EAJLc,EAAOlB,UAAW,IAIkB,CAEnC,GADA0B,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAK2C,EAAeQ,GAAS,CAE5B,GAAKd,EAAsBe,GAC1B,OAAOS,EAAMV,EAAMC,EAAMpC,EAAOhB,GAIjC,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAED,GAAKyC,EAAcU,GAAS,CAE3B,GADAQ,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAGD,GADA2D,EAAM7D,EAAUE,EAASoD,GAExB,MAAMO,EAEP,OAAOE,EAAMV,EAAMnC,EAAOhB,EAC1B,CAKD,GAHAmD,EAAOlB,UAAW,GAIjBI,EAAsBc,IACtBR,EAAeQ,IACfV,EAAcU,IACdN,EAAgBM,GAEhB,OAAOU,EAAMV,EAAMnC,EAAOhB,GAI3B,GADA2D,EAAM7D,EAAUE,EAASmD,GACpBQ,EACJ,MAAMA,EAEP,OAAOE,EAAM7C,EAAOhB,EACpB,CACF,CCpHA8D,EAAAD,EAAA,UAAAH"} \ No newline at end of file diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 3a3d55f35f9eae00183cd1751d4d0ea19beb2927 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 May 2026 09:42:04 +0000 Subject: [PATCH 55/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 108b66827d9889cd7b2a0e506fc73798dddf2cfd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 May 2026 09:42:26 +0000 Subject: [PATCH 56/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d2d3e56d6a1476e00582b7d8ae6c7da9204527d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 May 2026 09:43:13 +0000 Subject: [PATCH 57/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 110 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4893 insertions(+), 11032 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAc,QAAS,2CAA4C,EACnEC,EAAU,QAAS,sCAAuC,EAC1DC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACN,EAAWK,EAAK,QAAS,GACvB,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAGvHN,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACL,EAAaI,EAAK,IAAK,GACrB,IAAI,UAAWF,EAAQ,wEAAyE,OAAQE,EAAK,IAAK,CAAE,EAGxHN,EAAYO,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACJ,EAASG,EAAK,KAAM,GAClB,IAAI,UAAWF,EAAQ,qEAAsE,QAASE,EAAK,KAAM,CAAE,EAGrH,KApBC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAqBhH,CAKAT,EAAO,QAAUO,ICjFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAe,QAAS,8BAA+B,EACvDC,EAAgB,QAAS,+BAAgC,EACzDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAW,QAAS,0BAA2B,EAC/CC,EAAa,QAAS,0CAA2C,EACjEC,GAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,6BAA8B,EAChDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAO,QAAS,yBAA0B,EAC1CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAW,QAAS,0BAA2B,EAC/CC,GAAiB,QAAS,qCAAsC,EAChEC,GAAqB,QAAS,iCAAkC,EAChEC,EAAe,QAAS,2BAA4B,EACpDC,GAAa,QAAS,4BAA6B,EACnDC,GAAiB,QAAS,6BAA8B,EACxDC,EAAkB,QAAS,wCAAyC,EACpEC,GAAkB,QAAS,yBAA0B,EACrDC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBT,EAAS,IAAK,gBAAiB,EAC/CU,EAAgBV,EAAS,IAAK,OAAQ,EAY1C,SAASW,EAAmBC,EAAQ,CACnC,OAASA,IAAU,SACpB,CASA,SAASC,EAAkBD,EAAQ,CAClC,OAASA,IAAU,QACpB,CASA,SAASE,EAAcC,EAAU,CAChC,OAAKpB,GAAYoB,EAAS,OAAQ,EAC1BA,EAAQ,MAETL,CACR,CA8DA,SAASM,EAAoBJ,EAAOhB,EAAQqB,EAAQC,EAAQC,EAAYC,EAAOL,EAAU,CACxF,IAAIM,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKd,EAAmBC,CAAM,EAC7B,MAAM,IAAI,UAAWJ,EAAQ,2FAA4FI,CAAM,CAAE,EAwBlI,OAtBAa,EAAIN,EAGJK,EAAIP,EAASC,EAGRA,EAAS,IACbM,GAAK,GACLC,GAAKD,EAAIlB,EAAiBM,CAAM,GAG5BC,EAAkBD,CAAM,EAC5BS,EAAMnB,GAAoBN,EAAQ6B,EAAGD,CAAE,EAEvCH,EAAMxB,EAAYD,EAAQ6B,EAAGD,EAAGZ,CAAM,EAGvCU,EAAK,CAAEL,CAAO,EACdM,EAAK,CAAEL,CAAO,EACdO,EAAIxB,GAAgBqB,EAAIC,CAAG,EAGtB,UAAU,OAAS,EAChB,IAAIxB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,EAAOL,CAAQ,EAEpD,IAAIhB,EAASa,EAAOS,EAAKC,EAAIC,EAAIE,EAAGL,CAAM,CAClD,CAiFA,SAASM,EAAiBC,EAAKf,EAAOG,EAAU,CAC/C,IAAIa,EACAP,EASJ,OANKN,IAAY,KAChBa,EAAO,CAAC,EAERA,EAAOb,EAGH3B,EAAsBuC,CAAI,GAC9BN,EAAMzB,EAAQgB,EAAOe,CAAI,EAClB,IAAI5B,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFnC,EAAUkC,CAAI,GACbhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMjB,GAAYuB,CAAI,EAEtBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFtC,EAAcqC,CAAI,GACjBhB,EAAmBC,CAAM,EAC7BS,EAAMvB,EAAM6B,CAAI,EACLd,EAAkBD,CAAM,EACnCS,EAAMlB,EAAcwB,CAAI,EAExBN,EAAMxB,EAAY8B,EAAKf,CAAM,EAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFrC,EAAeoC,CAAI,EAChBX,EAAoBJ,EAAOe,EAAKA,EAAI,WAAWrB,EAAiBM,CAAM,EAAG,EAAG,EAAGE,EAAcc,CAAK,EAAGA,CAAK,EAG7GvC,EAAgBsC,CAAI,GACxBN,EAAMM,EAAKpB,EAAgB,EAAE,EAC7Bc,EAAMhB,GAAgBgB,CAAI,EACrBR,EAAkBD,CAAM,EAC5BS,EAAMlB,EAAckB,CAAI,EACZV,EAAmBC,CAAM,IACrCS,EAAMxB,EAAYwB,EAAKT,CAAM,GAEvB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAcc,CAAK,EAAGA,CAAK,GAGjFb,IAAY,MAAQvB,EAAemC,CAAI,GAC3CN,EAAMzB,EAAQgB,EAAO,CAAE,EAChB,IAAIb,EAASa,EAAOS,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGP,EAAca,CAAI,EAAGA,CAAI,GAE7E,IACR,CAyHA,SAASE,IAAS,CACjB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAd,EACAe,EAKJ,GAHAN,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAAT,EAAMzB,EAAQa,EAAe,CAAE,EACxB,IAAIV,EAASU,EAAeY,EAAK,CAAEA,EAAI,MAAO,EAAG,CAAE,CAAE,EAAG,EAAGX,CAAc,EAKjF,GAHAqB,EAAO,UAAW,CAAE,EAGfD,IAAU,EAAI,CAClB,GAAKpC,EAAYqC,CAAK,EACrB,OAAOL,EAAiB,EAAGK,EAAM,IAAK,EAGvC,GADAK,EAAMV,EAAiBK,EAAMtB,EAAe,IAAK,EAC5C2B,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,6IAA8IuB,CAAK,CAAE,EAEnL,OAAOK,CACR,CAIA,GAHAJ,EAAO,UAAW,CAAE,EAGfF,IAAU,EAAI,CAElB,GAAKpC,EAAYqC,CAAK,EAAI,CACzB,GAAKC,IAAS,KACb,MAAM,IAAI,UAAWxB,EAAQ,qEAAsEwB,CAAK,CAAE,EAE3G,OAAON,EAAiB,EAAGK,EAAMC,CAAK,CACvC,CAEA,GAAKtC,EAAYsC,CAAK,EAAI,CAEzB,GADAI,EAAMV,EAAiBK,EAAMC,EAAM,IAAK,EACnCI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAKhD,EAAsB4C,CAAK,EAAI,CACnC,GAAK,CAACzC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,OAAOf,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMtB,CAAc,CACjI,CAEA,GAAKsB,IAAS,KACb,MAAM,IAAI,UAAWxB,EAAQ,qEAAsEwB,CAAK,CAAE,EAG3G,GADAI,EAAMV,EAAiBK,EAAMtB,EAAeuB,CAAK,EAC5CI,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAIA,GAHAH,EAAO,UAAW,CAAE,EAGfH,IAAU,EAAI,CAElB,GAAKpC,EAAYuC,CAAK,EAAI,CACzB,GAAK,CAAC1C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,OAAOhB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMtB,CAAc,CAC/G,CAEA,GAAKhB,EAAYsC,CAAK,EAAI,CACzB,GAAKC,IAAS,KACb,MAAM,IAAI,UAAWzB,EAAQ,qEAAsEyB,CAAK,CAAE,EAG3G,GADAG,EAAMV,EAAiBK,EAAMC,EAAMC,CAAK,EACnCG,IAAQ,KACZ,MAAM,IAAI,UAAW5B,EAAQ,4HAA6HuB,CAAK,CAAE,EAElK,OAAOK,CACR,CAEA,GAAK,CAAC7C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAK5C,EAAsB6C,CAAK,EAC/B,OAAOjB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMtB,CAAc,EAG9E,GAAKuB,IAAS,KACb,MAAM,IAAI,UAAWzB,EAAQ,qEAAsEyB,CAAK,CAAE,EAE3G,OAAOjB,EAAoBP,EAAesB,GAAOA,EAAK,WAAWC,GAAM1B,EAAiBG,CAAc,EAAG,EAAGuB,EAAMlB,EAAcmB,CAAK,EAAGA,CAAK,CAC9I,CAIA,GAHAC,EAAO,UAAW,CAAE,EAGfJ,IAAU,EAAI,CAClB,GAAK,CAACvC,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAGlH,GAAK5C,EAAsB6C,CAAK,EAAI,CACnC,GAAKvC,EAAYwC,CAAK,EACrB,OAAOlB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMtB,CAAc,EAGrE,GAAK,CAAClB,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBP,EAAesB,EAAME,EAAM,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC3F,CAEA,GAAK,CAACxC,EAAYuC,CAAK,EACtB,MAAM,IAAI,UAAWzB,EAAQ,0FAA2FyB,CAAK,CAAE,EAEhI,GAAK,CAACzC,EAAe0C,CAAK,EACzB,MAAM,IAAI,UAAW1B,EAAQ,qEAAsE0B,CAAK,CAAE,EAE3G,OAAOlB,EAAoBiB,EAAMF,GAAOA,EAAK,WAAWC,GAAM1B,EAAiB2B,CAAK,EAAG,EAAGD,EAAMlB,EAAcoB,CAAK,EAAGA,CAAK,CAC5H,CAIA,GAHAC,EAAO,UAAW,CAAE,EAGf,CAAC5C,EAAewC,CAAK,EACzB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAK,CAAE,EAE9G,GAAK,CAAC3C,EAAsB4C,CAAK,EAChC,MAAM,IAAI,UAAWxB,EAAQ,4EAA6EwB,CAAK,CAAE,EAElH,GAAK,CAAC5C,EAAsB6C,CAAK,EAChC,MAAM,IAAI,UAAWzB,EAAQ,uEAAwEyB,CAAK,CAAE,EAE7G,GAAK,CAACvC,EAAYwC,CAAK,EACtB,MAAM,IAAI,UAAW1B,EAAQ,2FAA4F0B,CAAK,CAAE,EAEjI,GAAK,CAAC1C,EAAe2C,CAAK,EACzB,MAAM,IAAI,UAAW3B,EAAQ,qEAAsE2B,CAAK,CAAE,EAE3G,OAAOnB,EAAoBkB,EAAMH,EAAME,EAAM,EAAGD,EAAMlB,EAAcqB,CAAK,EAAGA,CAAK,CAClF,CAKAhD,EAAO,QAAU0C,KCjmBjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,GAAiB,QAAS,iCAAkC,EAC5DC,EAAgB,QAAS,+BAAgC,EACzDC,EAAe,QAAS,8BAA+B,EACvDC,GAAa,QAAS,0CAA2C,EACjEC,GAAe,QAAS,uBAAwB,EAChDC,GAAS,QAAS,uBAAwB,EAC1CC,EAAW,IACXC,EAAO,IAmGX,SAASC,GAASC,EAAOC,EAAU,CAClC,IAAIC,EACAC,EACJ,GAAK,CAACT,GAAYM,CAAM,EACvB,MAAM,IAAI,UAAWJ,GAAQ,+EAAgFI,CAAM,CAAE,EAGtH,GADAE,EAAO,CAAC,EACH,UAAU,OAAS,IACvBC,EAAMN,EAAUK,EAAMD,CAAQ,EACzBE,GACJ,MAAMA,EAGR,OAAOC,EAgBP,SAASA,GAAS,CACjB,IAAIH,EACAI,EACAC,EACAC,EACAJ,EAMJ,GAJAF,EAAUN,GAAc,CAAC,EAAGO,CAAK,EACjCG,EAAQ,UAAU,OAGbA,IAAU,EACd,OAAOP,EAAME,EAAOC,CAAQ,EAG7B,GAAKI,EAAQ,EAAI,CAEhB,GADAF,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7E,CAEA,GAAKI,IAAU,EAAI,CAElB,GAAKf,EAAsB,UAAW,CAAE,CAAE,EACzC,OAAOQ,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,EAI7E,GADAE,EAAMN,EAAUI,EAAS,UAAW,CAAE,CAAE,EACnCE,EACJ,MAAMA,EAEP,OAAOL,EAAM,UAAW,CAAE,EAAG,UAAW,CAAE,EAAGE,EAAOC,CAAQ,CAC7D,CAEA,GAAKI,IAAU,EAAI,CAKlB,GAJAC,EAAO,UAAW,CAAE,EACpBC,EAAO,UAAW,CAAE,EAGfjB,EAAsBgB,CAAK,EAAI,CAEnC,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKT,EAAec,CAAK,EAAI,CAE5B,GAAKhB,EAAsBiB,CAAK,EAC/B,OAAOT,EAAMQ,EAAMC,EAAMP,EAAOC,CAAQ,EAIzC,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAEA,GAAKR,EAAca,CAAK,EAAI,CAE3B,GADAH,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAGA,GADAE,EAAMN,EAAUI,EAASM,CAAK,EACzBJ,EACJ,MAAMA,EAEP,OAAOL,EAAMQ,EAAMN,EAAOC,CAAQ,CACnC,CAKA,GAHAK,EAAO,UAAW,CAAE,EAInBhB,EAAsBgB,CAAK,GAC3Bd,EAAec,CAAK,GACpBb,EAAca,CAAK,GACnBf,GAAgBe,CAAK,EAErB,OAAOR,EAAMQ,EAAMN,EAAOC,CAAQ,EAInC,GADAE,EAAMN,EAAUI,EAASK,CAAK,EACzBH,EACJ,MAAMA,EAEP,OAAOL,EAAME,EAAOC,CAAQ,CAC7B,CACD,CAKAZ,EAAO,QAAUU,KChIjB,IAAIS,GAAc,QAAS,uDAAwD,EAC/EC,GAAU,IACVC,EAAO,IAKXF,GAAaE,EAAM,UAAWD,EAAQ,EAKtC,OAAO,QAAUC", - "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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From eff3fb8247e821bc4555c7ffd9fe488a2063ef88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:47:49 +0000 Subject: [PATCH 58/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 4cfb2fba16d4798c75e3870423b3bbd9049ec714 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:57:35 +0000 Subject: [PATCH 59/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3f0a8b15e252c7653cae58b3b91d88b9ad85797c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:58:11 +0000 Subject: [PATCH 60/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 110 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4893 insertions(+), 11033 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 663543a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-17T03:39:51.683Z 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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 d6da18d..7b4722a 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..d36a098 --- /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@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-data-type@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import w 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@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";function L(r,e){return l(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(u("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(u("invalid option. `%s` option must be a valid index mode. Option: `%s`.","mode",r.mode)):a(e,"order")&&(r.order=e.order,!p(r.order))?new TypeError(u("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(u("null2V",e))}var C=x.get("dtypes.default"),z=x.get("order");function O(r){return"generic"===r}function M(r){return"binary"===r}function P(r){return b(r,"order")?r.order:z}function q(r,e,t,n,s,i,o){var d,l,a,m,f;if(O(r))throw new TypeError(u("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return f=s,m=t*n,n<0&&(f-=(m*=-1)*k(r)),d=M(r)?E(e,f,m):w(e,f,m,r),f=T(l=[t],a=[n]),arguments.length>6?new c(r,d,l,a,f,i,o):new c(r,d,l,a,f,i)}function D(r,i,o){var d,l;return d=null===o?{}:o,e(r)?(l=g(i,r),new c(i,l,[l.length],[1],0,P(d),d)):j(r)?(l=O(i)?v(r):M(i)?B(r):w(r,i),new c(i,l,[l.length],[1],0,P(d),d)):s(r)?(l=O(i)?v(r):M(i)?V(r):w(r,i),new c(i,l,[l.length],[1],0,P(d),d)):n(r)?q(i,r,r.byteLength/k(i),1,0,P(d),d):t(r)?(l=r[A](),l=F(l),M(i)?l=V(l):O(i)||(l=w(l,i)),new c(i,l,[l.length],[1],0,P(d),d)):null===o&&h(r)?(l=g(i,0),new c(i,l,[l.length],[1],0,P(r),r)):null}function G(){var r,t,s,i,o,d,l,a;if(0===(r=arguments.length))return l=g(C,0),new c(C,l,[l.length],[1],0,z);if(t=arguments[0],1===r){if(y(t))return D(0,t,null);if(null===(a=D(t,C,null)))throw new TypeError(u("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return a}if(s=arguments[1],2===r){if(y(t)){if(null===s)throw new TypeError(u("null2V",s));return D(0,t,s)}if(y(s)){if(null===(a=D(t,s,null)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(e(s)){if(!n(t))throw new TypeError(u("null2B",t));return q(C,t,(t.byteLength-s)/k(C),1,s,z)}if(null===s)throw new TypeError(u("null2V",s));if(null===(a=D(t,C,s)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(i=arguments[2],3===r){if(y(i)){if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));return q(i,t,(t.byteLength-s)/k(i),1,s,z)}if(y(s)){if(null===i)throw new TypeError(u("null2V",i));if(null===(a=D(t,s,i)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(e(i))return q(C,t,i,1,s,z);if(null===i)throw new TypeError(u("null2V",i));return q(C,t,(t.byteLength-s)/k(C),1,s,P(i),i)}if(o=arguments[3],4===r){if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(e(i)){if(y(o))return q(o,t,i,1,s,z);if(!h(o))throw new TypeError(u("null2V",o));return q(C,t,i,1,s,P(o),o)}if(!y(i))throw new TypeError(u("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",i));if(!h(o))throw new TypeError(u("null2V",o));return q(i,t,(t.byteLength-s)/k(i),1,s,P(o),o)}if(d=arguments[4],!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(!e(i))throw new TypeError(u("null2F",i));if(!y(o))throw new TypeError(u("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",o));if(!h(d))throw new TypeError(u("null2V",d));return q(o,t,i,1,s,P(d),d)}function H(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=L(a,l)))throw m;return function(){var i,d,l,m,f;if(i=o({},a),d=arguments.length,0===d)return G(r,i);if(d>3){if(f=L(i,arguments[3]))throw f;return G(arguments[0],arguments[1],arguments[2],r,i)}if(3===d){if(e(arguments[2]))return G(arguments[0],arguments[1],arguments[2],r,i);if(f=L(i,arguments[2]))throw f;return G(arguments[0],arguments[1],r,i)}if(2===d){if(m=arguments[1],e(l=arguments[0])){if(f=L(i,m))throw f;return G(l,r,i)}if(n(l)){if(e(m))return G(l,m,r,i);if(f=L(i,m))throw f;return G(l,r,i)}if(s(l)){if(f=L(i,m))throw f;return G(l,r,i)}if(f=L(i,m))throw f;return G(l,r,i)}if(l=arguments[0],e(l)||n(l)||s(l)||t(l))return G(l,r,i);if(f=L(i,l),f)throw f;return G(r,i)}}r(G,"factory",H);export{G as default,H as factory}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..464d47c --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..238a262 --- /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(); -}); From 79221325bee81d893781d2408fb9e331563770da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 03:50:14 +0000 Subject: [PATCH 61/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From a000586ddbd3a87c4f4c3b37c850917143e4e5bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:05:05 +0000 Subject: [PATCH 62/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d36a098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-index-mode@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-order@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-data-type@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs";import w 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@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@esm/index.mjs";import F from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@esm/index.mjs";function L(r,e){return l(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(u("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(u("invalid option. `%s` option must be a valid index mode. Option: `%s`.","mode",r.mode)):a(e,"order")&&(r.order=e.order,!p(r.order))?new TypeError(u("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(u("null2V",e))}var C=x.get("dtypes.default"),z=x.get("order");function O(r){return"generic"===r}function M(r){return"binary"===r}function P(r){return b(r,"order")?r.order:z}function q(r,e,t,n,s,i,o){var d,l,a,m,f;if(O(r))throw new TypeError(u("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return f=s,m=t*n,n<0&&(f-=(m*=-1)*k(r)),d=M(r)?E(e,f,m):w(e,f,m,r),f=T(l=[t],a=[n]),arguments.length>6?new c(r,d,l,a,f,i,o):new c(r,d,l,a,f,i)}function D(r,i,o){var d,l;return d=null===o?{}:o,e(r)?(l=g(i,r),new c(i,l,[l.length],[1],0,P(d),d)):j(r)?(l=O(i)?v(r):M(i)?B(r):w(r,i),new c(i,l,[l.length],[1],0,P(d),d)):s(r)?(l=O(i)?v(r):M(i)?V(r):w(r,i),new c(i,l,[l.length],[1],0,P(d),d)):n(r)?q(i,r,r.byteLength/k(i),1,0,P(d),d):t(r)?(l=r[A](),l=F(l),M(i)?l=V(l):O(i)||(l=w(l,i)),new c(i,l,[l.length],[1],0,P(d),d)):null===o&&h(r)?(l=g(i,0),new c(i,l,[l.length],[1],0,P(r),r)):null}function G(){var r,t,s,i,o,d,l,a;if(0===(r=arguments.length))return l=g(C,0),new c(C,l,[l.length],[1],0,z);if(t=arguments[0],1===r){if(y(t))return D(0,t,null);if(null===(a=D(t,C,null)))throw new TypeError(u("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return a}if(s=arguments[1],2===r){if(y(t)){if(null===s)throw new TypeError(u("null2V",s));return D(0,t,s)}if(y(s)){if(null===(a=D(t,s,null)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(e(s)){if(!n(t))throw new TypeError(u("null2B",t));return q(C,t,(t.byteLength-s)/k(C),1,s,z)}if(null===s)throw new TypeError(u("null2V",s));if(null===(a=D(t,C,s)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(i=arguments[2],3===r){if(y(i)){if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));return q(i,t,(t.byteLength-s)/k(i),1,s,z)}if(y(s)){if(null===i)throw new TypeError(u("null2V",i));if(null===(a=D(t,s,i)))throw new TypeError(u("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return a}if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(e(i))return q(C,t,i,1,s,z);if(null===i)throw new TypeError(u("null2V",i));return q(C,t,(t.byteLength-s)/k(C),1,s,P(i),i)}if(o=arguments[3],4===r){if(!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(e(i)){if(y(o))return q(o,t,i,1,s,z);if(!h(o))throw new TypeError(u("null2V",o));return q(C,t,i,1,s,P(o),o)}if(!y(i))throw new TypeError(u("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",i));if(!h(o))throw new TypeError(u("null2V",o));return q(i,t,(t.byteLength-s)/k(i),1,s,P(o),o)}if(d=arguments[4],!n(t))throw new TypeError(u("null2B",t));if(!e(s))throw new TypeError(u("null2C",s));if(!e(i))throw new TypeError(u("null2F",i));if(!y(o))throw new TypeError(u("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",o));if(!h(d))throw new TypeError(u("null2V",d));return q(o,t,i,1,s,P(d),d)}function H(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=L(a,l)))throw m;return function(){var i,d,l,m,f;if(i=o({},a),d=arguments.length,0===d)return G(r,i);if(d>3){if(f=L(i,arguments[3]))throw f;return G(arguments[0],arguments[1],arguments[2],r,i)}if(3===d){if(e(arguments[2]))return G(arguments[0],arguments[1],arguments[2],r,i);if(f=L(i,arguments[2]))throw f;return G(arguments[0],arguments[1],r,i)}if(2===d){if(m=arguments[1],e(l=arguments[0])){if(f=L(i,m))throw f;return G(l,r,i)}if(n(l)){if(e(m))return G(l,m,r,i);if(f=L(i,m))throw f;return G(l,r,i)}if(s(l)){if(f=L(i,m))throw f;return G(l,r,i)}if(f=L(i,m))throw f;return G(l,r,i)}if(l=arguments[0],e(l)||n(l)||s(l)||t(l))return G(l,r,i);if(f=L(i,l),f)throw f;return G(r,i)}}r(G,"factory",H);export{G as default,H as factory}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 464d47c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 238a262..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2b09eee490307e26a8ac03aad08a0324b1551bc4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:05:59 +0000 Subject: [PATCH 63/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 110 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4893 insertions(+), 11046 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 662666a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-20T03:38:17.662Z 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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 d6da18d..7b4722a 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..8b9c342 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function F(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(p("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(p("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(p("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(p("null2V",e))}var k=w.get("dtypes.default"),A=w.get("order");function L(r){return"generic"===r}function C(r){return"binary"===r}function z(r){return a(r,"order")?r.order:A}function O(r,e,t,n,i,s,o){var d,a,m,f,u;if(L(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*V(r)),d=C(r)?c(e,u,f):j(e,u,f,r),u=g(a=[t],m=[n]),arguments.length>6?new v(r,d,a,m,u,s,o):new v(r,d,a,m,u,s)}function M(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=y(s,r),new v(s,a,[a.length],[1],0,z(l),l)):h(r)?(a=L(s)?b(r):C(s)?T(r):j(r,s),new v(s,a,[a.length],[1],0,z(l),l)):i(r)?(a=L(s)?b(r):C(s)?x(r):j(r,s),new v(s,a,[a.length],[1],0,z(l),l)):n(r)?O(s,r,r.byteLength/V(s),1,0,z(l),l):t(r)?(a=r[B](),a=E(a),C(s)?a=x(a):L(s)||(a=j(a,s)),new v(s,a,[a.length],[1],0,z(l),l)):null===o&&d(r)?(a=y(s,0),new v(s,a,[a.length],[1],0,z(r),r)):null}function P(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=y(k,0),new v(k,f,[f.length],[1],0,A);if(t=arguments[0],1===r){if(s(t))return M(0,t,null);if(null===(u=M(t,k,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return M(0,t,i)}if(s(i)){if(null===(u=M(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return O(k,t,(t.byteLength-i)/V(k),1,i,A)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=M(t,k,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return O(o,t,(t.byteLength-i)/V(o),1,i,A)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=M(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return O(k,t,o,1,i,A);if(null===o)throw new TypeError(l("null2V",o));return O(k,t,(t.byteLength-i)/V(k),1,i,z(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return O(a,t,o,1,i,A);if(!d(a))throw new TypeError(l("null2V",a));return O(k,t,o,1,i,z(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return O(o,t,(t.byteLength-i)/V(o),1,i,z(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return O(a,t,o,1,i,z(m),m)}function q(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=F(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return P(r,s);if(l>3){if(f=F(s,arguments[3]))throw f;return P(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return P(arguments[0],arguments[1],arguments[2],r,s);if(f=F(s,arguments[2]))throw f;return P(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=F(s,m))throw f;return P(d,r,s)}if(n(d)){if(e(m))return P(d,m,r,s);if(f=F(s,m))throw f;return P(d,r,s)}if(i(d)){if(f=F(s,m))throw f;return P(d,r,s)}if(f=F(s,m))throw f;return P(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return P(d,r,s);if(f=F(s,d),f)throw f;return P(r,s)}}r(P,"factory",q);export{P as default,q as factory}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..094f50c --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..ec6f6b4 --- /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(); -}); From 01908067924faf76d7343e9a3f1fd935bf5b69c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:23:06 +0000 Subject: [PATCH 64/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index af6ef6b..baae0b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -42,7 +42,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -482,7 +482,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -497,13 +497,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -518,17 +518,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -538,10 +538,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -549,7 +549,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -558,10 +558,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -570,7 +570,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -579,7 +579,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -587,19 +587,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index 359efaa..763e2de 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 1a51b8216998ae12568cfea652e15b622fec3d00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:24:40 +0000 Subject: [PATCH 65/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8b9c342..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import B from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function F(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(p("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(p("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(p("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(p("null2V",e))}var k=w.get("dtypes.default"),A=w.get("order");function L(r){return"generic"===r}function C(r){return"binary"===r}function z(r){return a(r,"order")?r.order:A}function O(r,e,t,n,i,s,o){var d,a,m,f,u;if(L(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*V(r)),d=C(r)?c(e,u,f):j(e,u,f,r),u=g(a=[t],m=[n]),arguments.length>6?new v(r,d,a,m,u,s,o):new v(r,d,a,m,u,s)}function M(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=y(s,r),new v(s,a,[a.length],[1],0,z(l),l)):h(r)?(a=L(s)?b(r):C(s)?T(r):j(r,s),new v(s,a,[a.length],[1],0,z(l),l)):i(r)?(a=L(s)?b(r):C(s)?x(r):j(r,s),new v(s,a,[a.length],[1],0,z(l),l)):n(r)?O(s,r,r.byteLength/V(s),1,0,z(l),l):t(r)?(a=r[B](),a=E(a),C(s)?a=x(a):L(s)||(a=j(a,s)),new v(s,a,[a.length],[1],0,z(l),l)):null===o&&d(r)?(a=y(s,0),new v(s,a,[a.length],[1],0,z(r),r)):null}function P(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=y(k,0),new v(k,f,[f.length],[1],0,A);if(t=arguments[0],1===r){if(s(t))return M(0,t,null);if(null===(u=M(t,k,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return M(0,t,i)}if(s(i)){if(null===(u=M(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return O(k,t,(t.byteLength-i)/V(k),1,i,A)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=M(t,k,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return O(o,t,(t.byteLength-i)/V(o),1,i,A)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=M(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return O(k,t,o,1,i,A);if(null===o)throw new TypeError(l("null2V",o));return O(k,t,(t.byteLength-i)/V(k),1,i,z(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return O(a,t,o,1,i,A);if(!d(a))throw new TypeError(l("null2V",a));return O(k,t,o,1,i,z(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return O(o,t,(t.byteLength-i)/V(o),1,i,z(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return O(a,t,o,1,i,z(m),m)}function q(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=F(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return P(r,s);if(l>3){if(f=F(s,arguments[3]))throw f;return P(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return P(arguments[0],arguments[1],arguments[2],r,s);if(f=F(s,arguments[2]))throw f;return P(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=F(s,m))throw f;return P(d,r,s)}if(n(d)){if(e(m))return P(d,m,r,s);if(f=F(s,m))throw f;return P(d,r,s)}if(i(d)){if(f=F(s,m))throw f;return P(d,r,s)}if(f=F(s,m))throw f;return P(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return P(d,r,s);if(f=F(s,d),f)throw f;return P(r,s)}}r(P,"factory",q);export{P as default,q as factory}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 094f50c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index ec6f6b4..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 73e184889f1e10cf8822b6cd2e7e6aef794528ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:25:23 +0000 Subject: [PATCH 66/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 110 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 610 --- lib/validate.js | 82 - package.json | 101 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 52 files changed, 4893 insertions(+), 11046 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 8feb2ac..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-21T03:21:45.086Z 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 21f56f1..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(); - - -// 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 5cc171a..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(); - - -// 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 960604a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var D=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};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"),q=require("@stdlib/assert-is-arraybuffer"),O=require("@stdlib/assert-is-plain-object"),$=require("@stdlib/assert-is-buffer"),y=require("@stdlib/ndarray-base-assert-is-data-type"),rr=require("@stdlib/assert-has-own-property"),k=require("@stdlib/ndarray-base-buffer"),j=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"),f=require("@stdlib/string-format"),v=_.get("dtypes.default"),E=_.get("order");function A(e){return e==="generic"}function F(e){return e==="binary"}function g(e){return rr(e,"order")?e.order:E}function b(e,r,t,a,n,u,l){var i,s,o,V,d;if(A(e))throw new TypeError(f("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",e));return d=n,V=t*a,a<0&&(V*=-1,d-=V*p(e)),F(e)?i=ar(r,d,V):i=j(r,d,V,e),s=[t],o=[a],d=er(s,o),arguments.length>6?new h(e,i,s,o,d,u,l):new h(e,i,s,o,d,u)}function T(e,r,t){var a,n;return t===null?a={}:a=t,w(e)?(n=k(r,e),new h(r,n,[n.length],[1],0,g(a),a)):$(e)?(A(r)?n=R(e):F(r)?n=nr(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):Z(e)?(A(r)?n=R(e):F(r)?n=M(e):n=j(e,r),new h(r,n,[n.length],[1],0,g(a),a)):q(e)?b(r,e,e.byteLength/p(r),1,0,g(a),a):X(e)?(n=e[ir](),n=tr(n),F(r)?n=M(n):A(r)||(n=j(n,r)),new h(r,n,[n.length],[1],0,g(a),a)):t===null&&O(e)?(n=k(r,0),new h(r,n,[n.length],[1],0,g(e),e)):null}function ur(){var e,r,t,a,n,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 T(0,r,null);if(i=T(r,v,null),i===null)throw new TypeError(f("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",r));return i}if(t=arguments[1],e===2){if(y(r)){if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));return T(0,r,t)}if(y(t)){if(i=T(r,t,null),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(w(t)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));return b(v,r,(r.byteLength-t)/p(v),1,t,E)}if(t===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));if(i=T(r,v,t),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(a=arguments[2],e===3){if(y(a)){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));return b(a,r,(r.byteLength-t)/p(a),1,t,E)}if(y(t)){if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));if(i=T(r,t,a),i===null)throw new TypeError(f("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",r));return i}if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a))return b(v,r,a,1,t,E);if(a===null)throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",a));return b(v,r,(r.byteLength-t)/p(v),1,t,g(a),a)}if(n=arguments[3],e===4){if(!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(w(a)){if(y(n))return b(n,r,a,1,t,E);if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(v,r,a,1,t,g(n),n)}if(!y(a))throw new TypeError(f("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",a));if(!O(n))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",n));return b(a,r,(r.byteLength-t)/p(a),1,t,g(n),n)}if(u=arguments[4],!q(r))throw new TypeError(f("invalid argument. First argument must be an ArrayBuffer. Value: `%s`.",r));if(!w(t))throw new TypeError(f("invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.",t));if(!w(a))throw new TypeError(f("invalid argument. Length must be a nonnegative integer. Value: `%s`.",a));if(!y(n))throw new TypeError(f("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",n));if(!O(u))throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",u));return b(n,r,a,1,t,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"),fr=require("@stdlib/ndarray-base-assert-is-data-type"),sr=require("@stdlib/object-assign"),lr=require("@stdlib/string-format"),c=N(),m=x();function mr(e,r){var t,a;if(!fr(e))throw new TypeError(lr("invalid argument. First argument must be a supported data type. Value: `%s`.",e));if(t={},arguments.length>1&&(a=c(t,r),a))throw a;return n;function n(){var u,l,i,s,o;if(u=sr({},t),l=arguments.length,l===0)return m(e,u);if(l>3){if(o=c(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=c(u,arguments[2]),o)throw o;return m(arguments[0],arguments[1],e,u)}if(l===2){if(i=arguments[0],s=arguments[1],L(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(C(i)){if(L(s))return m(i,s,e,u);if(o=c(u,s),o)throw o;return m(i,e,u)}if(U(i)){if(o=c(u,s),o)throw o;return m(i,e,u)}if(o=c(u,s),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=c(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 0ccab7b..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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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", "isDataType", "hasOwnProp", "buffer", "typedarray", "copy", "ndarray", "defaults", "strides2offset", "arraybuffer2buffer", "array2buffer", "copyBuffer", "iterator2array", "bytesPerElement", "ITERATOR_SYMBOL", "format", "DEFAULT_DTYPE", "DEFAULT_ORDER", "isGenericDataType", "dtype", "isBinaryDataType", "resolveOrder", "options", "arraybuffer2vector", "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 d6da18d..7b4722a 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..abf62a9 --- /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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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..a5914bd --- /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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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 321f881..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/error-tools-fmtprodmsg' ); -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 baae0b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,610 +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 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/error-tools-fmtprodmsg' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var DEFAULT_ORDER = defaults.get( 'order' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a "generic" data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isGenericDataType( dtype ) { - return ( dtype === 'generic' ); -} - -/** -* Tests whether a data type is a binary data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} result -*/ -function isBinaryDataType( dtype ) { - return ( dtype === 'binary' ); -} - -/** -* 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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides` - 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 ); - } - // 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 763e2de..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,80 +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-data-type": "^0.2.3", - "@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/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@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..2d6ab0c --- /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(); -}); From 6fbe21a52d7c300bd074a1d3e0e709a42d89d5bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Jun 2026 11:17:34 +0000 Subject: [PATCH 67/69] Transform error messages --- lib/factory.js | 2 +- lib/main.js | 36 ++++++++++++++++++------------------ lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 29796e2..321f881 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -28,7 +28,7 @@ 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 format = require( '@stdlib/error-tools-fmtprodmsg' ); var validate = require( './validate.js' ); var main = require( './main.js' ); diff --git a/lib/main.js b/lib/main.js index 1f88cd8..441b5f0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -44,7 +44,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // VARIABLES // @@ -462,7 +462,7 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } return vectorWithDType( 0, arg0, arg1 ); } @@ -477,13 +477,13 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', 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 ) ); + throw new TypeError( format( 'null2V', arg1 ) ); } out = vectorWithDType( arg0, DEFAULT_DTYPE, arg1 ); if ( out === null ) { @@ -498,17 +498,17 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', 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 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } out = vectorWithDType( arg0, arg1, arg2 ); if ( out === null ) { @@ -518,10 +518,10 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, arg2 ) if ( !isArrayBuffer( arg0 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg0 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length ) if ( isNonNegativeInteger( arg2 ) ) { @@ -529,7 +529,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, options ) if ( arg2 === null ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2V', arg2 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, (arg0.byteLength-arg1)/bytesPerElement( DEFAULT_DTYPE ), 1, arg1, resolveOrder( arg2 ), arg2 ); } @@ -538,10 +538,10 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } // Case: vector( ArrayBuffer, byteOffset, length, dtype ) if ( isNonNegativeInteger( arg2 ) ) { @@ -550,7 +550,7 @@ function vector() { } // Case: vector( ArrayBuffer, byteOffset, length, options ) if ( !isPlainObject( arg3 ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', arg3 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( DEFAULT_DTYPE, arg0, arg2, 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -559,7 +559,7 @@ function vector() { 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 ) ); + throw new TypeError( format( 'null2V', arg3 ) ); } return arraybuffer2vector( arg2, arg0, (arg0.byteLength-arg1)/bytesPerElement( arg2 ), 1, arg1, resolveOrder( arg3 ), arg3 ); } @@ -567,19 +567,19 @@ function vector() { // 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 ) ); + throw new TypeError( format( 'null2B', arg0 ) ); } if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', arg1 ) ); + throw new TypeError( format( 'null2C', arg1 ) ); } if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', arg2 ) ); + throw new TypeError( format( 'null2F', 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 ) ); + throw new TypeError( format( 'null2V', arg4 ) ); } return arraybuffer2vector( arg3, arg0, arg2, 1, arg1, resolveOrder( arg4 ), arg4 ); } diff --git a/lib/validate.js b/lib/validate.js index dc0185e..672dfb6 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ 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' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -53,12 +53,12 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( 'null2V', 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 ) ); + return new TypeError( format( 'null2o', 'readonly', opts.readonly ) ); } } if ( hasOwnProp( options, 'mode' ) ) { diff --git a/package.json b/package.json index abb61a9..5577a04 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@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/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", From 3b61fccdca0787605a71881f33d5c20138dcd98d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Jun 2026 11:18:23 +0000 Subject: [PATCH 68/69] Remove files --- index.d.ts | 927 ---------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5774 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b4722a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,927 +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. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { DataTypeMap, TypedDataTypeMap, Order, Mode } from '@stdlib/types/ndarray'; -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Array order (either 'row-major' (C-style) or 'column-major' (Fortran-style)). - */ - order?: Order; - - /** - * Specifies how to handle a linear index which exceeds array dimensions (default: 'throw'). - */ - mode?: Mode; - - /** - * Boolean indicating whether an array should be read-only (default: false). - */ - readonly?: boolean; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface GenericVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): DataTypeMap['generic']; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): DataTypeMap['generic']; -} - -/** -* Interface for the function returned by the factory method. -*/ -interface TypedVector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( length: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( obj: Collection | AccessorArrayLike | Iterable, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, options?: Options ): TypedDataTypeMap[T]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options?: Options ): TypedDataTypeMap[T]; -} - -/** -* Interface for creating a vector (i.e., a one-dimensional ndarray). -*/ -interface Vector { - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector(); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( {} ); - * // returns - * - * var len = numel( arr ); - * // returns 0 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - = 'float64'>( length: number, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param length - vector length - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( length: number, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ] ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1, 2 ], 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, dtype?: U, options?: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param obj - array-like object or iterable from which to generate a vector - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * - * var arr = vector( [ 1.0, 2.0 ], {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - = 'float64'>( obj: Collection | AccessorArrayLike | Iterable, options: Options ): DataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 4 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, 'float32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8 ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = vector( buf, 8, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 1 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2 ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32' ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, 'int32', {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'int32' - */ - ( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: U, options?: Options ): TypedDataTypeMap[U]; - - /** - * Creates a vector (i.e., a one-dimensional ndarray). - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first vector element - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector - * @param options.mode - specifies how to handle indices which exceed vector dimensions - * @param options.order - memory layout (either row-major or column-major) - * @returns one-dimensional ndarray - * - * @example - * var numel = require( '@stdlib/ndarray-numel' ); - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = vector( buf, 8, 2, {} ); - * // returns - * - * var len = numel( arr ); - * // returns 2 - * - * var dt = getDType( arr ); - * // returns 'float64' - */ - ( buffer: ArrayBuffer, byteOffset: number, length: number, options: Options ): TypedDataTypeMap[U]; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var Float32Vector = vector.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 = vector.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 = vector.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 = vector.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 = vector.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 - */ - factory( dtype: T, options?: Options ): TypedVector; - - /** - * Returns a function for creating a vector (i.e., a one-dimensional ndarray). - * - * @param dtype - data type - * @param options - function options - * @param options.readonly - boolean indicating whether to return a read-only vector by default - * @param options.mode - specifies the default behavior when handling indices which exceed vector dimensions - * @param options.order - default memory layout (either row-major or column-major) - * @returns function for creating a vector - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( [ 1, 2, 3 ] ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - * - * @example - * var getDType = require( '@stdlib/ndarray-dtype' ); - * var numel = require( '@stdlib/ndarray-numel' ); - * - * var GenericVector = vector.factory( 'generic' ); - * - * var arr = new GenericVector( 3 ); - * // returns - * - * var dt = getDType( arr ); - * // returns 'generic' - * - * var len = numel( arr ); - * // returns 3 - */ - factory( dtype: 'generic', options?: Options ): GenericVector; -} - -/** -* Creates a vector (i.e., a one-dimensional ndarray). -* -* @param arg - length, typed array, array-like object, buffer, or iterable -* @param byteOffset - integer byte offset specifying the location of the first vector element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @param options - function options -* @param options.readonly - boolean indicating whether to return a read-only vector -* @param options.mode - specifies how to handle indices which exceed vector dimensions -* @param options.order - memory layout (either row-major or column-major) -* @returns 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 numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32' ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var numel = require( '@stdlib/ndarray-numel' ); -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = vector( buf, 8, 2, 'int32', {} ); -* // returns -* -* var len = numel( arr ); -* // returns 2 -* -* var dt = getDType( arr ); -* // returns 'int32' -* -* @example -* var getDType = require( '@stdlib/ndarray-dtype' ); -* var numel = require( '@stdlib/ndarray-numel' ); -* -* var Float32Vector = vector.factory( 'float32' ); -* -* var arr = new Float32Vector( [ 1, 2, 3 ] ); -* // returns -* -* var dt = getDType( arr ); -* // returns 'float32' -* -* var len = numel( arr ); -* // returns 3 -*/ -declare var vector: Vector; - - -// EXPORTS // - -export = vector; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abf62a9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// 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 i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import s 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 l from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import d 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-buffer@v0.3.1-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-typed@v0.3.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-defaults@v0.4.1-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-arraybuffer@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-array@v0.2.3-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-from-buffer@v0.2.3-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.3.1-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";function B(r,e){return d(e)?a(e,"readonly")&&(r.readonly=e.readonly,!m(r.readonly))?new TypeError(l("null2o","readonly",r.readonly)):a(e,"mode")&&(r.mode=e.mode,!f(r.mode))?new TypeError(l("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(l("invalid option. `%s` option must be a memory layout. Option: `%s`.","order",r.order)):null:new TypeError(l("null2V",e))}var F=v.get("dtypes.default"),k=v.get("order");function A(r){return"generic"===r}function L(r){return"binary"===r}function C(r){return a(r,"order")?r.order:k}function z(r,e,t,n,i,s,o){var d,a,m,f,u;if(A(r))throw new TypeError(l("invalid argument. ArrayBuffer is incompatible with the specified data type. Value: `%s`.",r));return u=i,f=t*n,n<0&&(u-=(f*=-1)*E(r)),d=L(r)?g(e,u,f):y(e,u,f,r),u=w(a=[t],m=[n]),arguments.length>6?new b(r,d,a,m,u,s,o):new b(r,d,a,m,u,s)}function O(r,s,o){var l,a;return l=null===o?{}:o,e(r)?(a=h(s,r),new b(s,a,[a.length],[1],0,C(l),l)):p(r)?(a=A(s)?j(r):L(s)?T(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):i(r)?(a=A(s)?j(r):L(s)?c(r):y(r,s),new b(s,a,[a.length],[1],0,C(l),l)):n(r)?z(s,r,r.byteLength/E(s),1,0,C(l),l):t(r)?(a=r[V](),a=x(a),L(s)?a=c(a):A(s)||(a=y(a,s)),new b(s,a,[a.length],[1],0,C(l),l)):null===o&&d(r)?(a=h(s,0),new b(s,a,[a.length],[1],0,C(r),r)):null}function M(){var r,t,i,o,a,m,f,u;if(0===(r=arguments.length))return f=h(F,0),new b(F,f,[f.length],[1],0,k);if(t=arguments[0],1===r){if(s(t))return O(0,t,null);if(null===(u=O(t,F,null)))throw new TypeError(l("invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, iterable, data type, or options object. Value: `%s`.",t));return u}if(i=arguments[1],2===r){if(s(t)){if(null===i)throw new TypeError(l("null2V",i));return O(0,t,i)}if(s(i)){if(null===(u=O(t,i,null)))throw new TypeError(l("invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.",t));return u}if(e(i)){if(!n(t))throw new TypeError(l("null2B",t));return z(F,t,(t.byteLength-i)/E(F),1,i,k)}if(null===i)throw new TypeError(l("null2V",i));if(null===(u=O(t,F,i)))throw new TypeError(l("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(s(o)){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));return z(o,t,(t.byteLength-i)/E(o),1,i,k)}if(s(i)){if(null===o)throw new TypeError(l("null2V",o));if(null===(u=O(t,i,o)))throw new TypeError(l("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(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o))return z(F,t,o,1,i,k);if(null===o)throw new TypeError(l("null2V",o));return z(F,t,(t.byteLength-i)/E(F),1,i,C(o),o)}if(a=arguments[3],4===r){if(!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(e(o)){if(s(a))return z(a,t,o,1,i,k);if(!d(a))throw new TypeError(l("null2V",a));return z(F,t,o,1,i,C(a),a)}if(!s(o))throw new TypeError(l("invalid argument. Third argument must be a recognized/supported data type. Value: `%s`.",o));if(!d(a))throw new TypeError(l("null2V",a));return z(o,t,(t.byteLength-i)/E(o),1,i,C(a),a)}if(m=arguments[4],!n(t))throw new TypeError(l("null2B",t));if(!e(i))throw new TypeError(l("null2C",i));if(!e(o))throw new TypeError(l("null2F",o));if(!s(a))throw new TypeError(l("invalid argument. Fourth argument must be a recognized/supported data type. Value: `%s`.",a));if(!d(m))throw new TypeError(l("null2V",m));return z(a,t,o,1,i,C(m),m)}function P(r,d){var a,m;if(!s(r))throw new TypeError(l("invalid argument. First argument must be a supported data type. Value: `%s`.",r));if(a={},arguments.length>1&&(m=B(a,d)))throw m;return function(){var s,l,d,m,f;if(s=o({},a),l=arguments.length,0===l)return M(r,s);if(l>3){if(f=B(s,arguments[3]))throw f;return M(arguments[0],arguments[1],arguments[2],r,s)}if(3===l){if(e(arguments[2]))return M(arguments[0],arguments[1],arguments[2],r,s);if(f=B(s,arguments[2]))throw f;return M(arguments[0],arguments[1],r,s)}if(2===l){if(m=arguments[1],e(d=arguments[0])){if(f=B(s,m))throw f;return M(d,r,s)}if(n(d)){if(e(m))return M(d,m,r,s);if(f=B(s,m))throw f;return M(d,r,s)}if(i(d)){if(f=B(s,m))throw f;return M(d,r,s)}if(f=B(s,m))throw f;return M(d,r,s)}if(d=arguments[0],e(d)||n(d)||i(d)||t(d))return M(d,r,s);if(f=B(s,d),f)throw f;return M(r,s)}}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 deleted file mode 100644 index a5914bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"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 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* Tests whether a data type is a \"generic\" data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isGenericDataType( dtype ) {\n\treturn ( dtype === 'generic' );\n}\n\n/**\n* Tests whether a data type is a binary data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} result\n*/\nfunction isBinaryDataType( dtype ) {\n\treturn ( dtype === 'binary' );\n}\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: consider moving to `@stdlib/ndarray/from-arraybuffer` and generalize to n-dimensions such that `length` becomes `shape` and `stride` becomes `strides`\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 );\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","isGenericDataType","dtype","isBinaryDataType","resolveOrder","arraybuffer2vector","buffer","length","stride","byteOffset","buf","sh","st","N","o","bytesPerElement","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/stats.html b/stats.html deleted file mode 100644 index 2d6ab0c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4a666222b59c32e211663f86674e1e1bac7b7d9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 24 Jun 2026 11:19:02 +0000 Subject: [PATCH 69/69] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 114 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 89 +- SECURITY.md | 5 - benchmark/benchmark.factory.js | 318 -- benchmark/benchmark.factory.size.js | 107 - benchmark/benchmark.js | 264 - benchmark/benchmark.size.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 246 - docs/types/test.ts | 154 - examples/index.js | 50 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/factory.js | 261 - lib/index.js | 147 - lib/main.js | 590 --- lib/validate.js | 82 - package.json | 103 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 1515 ------ test/test.js | 39 - test/test.main.js | 3173 ------------ test/test.validate.js | 184 - 51 files changed, 4893 insertions(+), 11031 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.factory.js delete mode 100644 benchmark/benchmark.factory.size.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.size.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/factory.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.validate.js 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 321f881..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/error-tools-fmtprodmsg' ); -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 441b5f0..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', 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( 'null2B', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', 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( 'null2V', 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( 'null2V', 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( 'null2B', arg0 ) ); - } - if ( !isNonNegativeInteger( arg1 ) ) { - throw new TypeError( format( 'null2C', arg1 ) ); - } - if ( !isNonNegativeInteger( arg2 ) ) { - throw new TypeError( format( 'null2F', 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( 'null2V', 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 672dfb6..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/error-tools-fmtprodmsg' ); - - -// 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( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'readonly' ) ) { - opts.readonly = options.readonly; - if ( !isBoolean( opts.readonly ) ) { - return new TypeError( format( 'null2o', '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 5577a04..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/error-tools-fmtprodmsg": "^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(); -});