From 301e7b4c7e7e9a872deaa1118c0ade2691572121 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 5 Apr 2025 09:31:31 +0000 Subject: [PATCH 01/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index f207ebc..0542b05 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index 6f2f501..8f757df 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 65cd31ce8325addd8b6d6affd0ec0525e5fb7cee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 5 Apr 2025 09:32:22 +0000 Subject: [PATCH 02/57] 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 | 87 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 105 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 87 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4892 insertions(+), 4819 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -379,7 +376,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -442,13 +439,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index ff5d505..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,z){z.exports={dims:null,keepdims:!1}});var c=q(function(jr,T){"use strict";var E=require("@stdlib/assert-is-plain-object"),h=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),S=require("@stdlib/array-base-join"),p=require("@stdlib/string-format");function P(r,e,a){var i;if(!E(a))return new TypeError(p("invalid argument. Options argument must be an object. Value: `%s`.",a));if(h(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(p("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(h(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(p("invalid options. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(p("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",S(r.dims,",")));if(i.length>e)return new RangeError(p("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",e,S(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),b=require("@stdlib/string-format"),nr=g(),ur=c();function sr(r,e,a){var i,n,o,v,u,t,d,m,l,f,s;if(!k(r))throw new TypeError(b("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),l=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,l,a),o))throw o;if(i.dims===null&&(i.dims=ir(l)),v=U(l,i.dims),t=ar(u,v),m=j(r),d=O(r),k(e)){if(!H(j(e),m))throw new TypeError(b("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{f=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,m))f=rr(e,m,t,d);else throw new TypeError(b("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,0),Z(s),O(s)),J(K,[r,n,f],i.dims),i.keepdims&&(s=Q(l,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),w=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),yr=require("@stdlib/ndarray-base-broadcast-scalar"),fr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),y=require("@stdlib/string-format"),cr=g(),br=c();function wr(r,e,a,i){var n,o,v,u,t,d;if(!w(r))throw new TypeError(y("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!w(a))throw new TypeError(y("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=fr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),w(e)){if(!dr(R(e),u))throw new TypeError(y("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(m){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=yr(e,u,A(a),v);else throw new TypeError(y("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),M=C(),Sr=D();hr(M,"assign",Sr);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 cb3146d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid options. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index c22af2a..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,105 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..233b563 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid options. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=b(R,{dtype:"bool",order:A}),S=new c("uint8",u(l(F),0),R,p(F,0),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,b,c,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),c=h(e),b=o(e),r(d)){if(!t(h(d),c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,c,m(a),b)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..505bb86 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid options. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","Error","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0542b05..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 8f757df..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid options. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..92d49d8 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From f2990a7e132ca4946aa9c76e63004f9f27d9aa44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 10 Apr 2025 00:48:14 +0000 Subject: [PATCH 03/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index f207ebc..0542b05 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index 0f645b7..e114626 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 32a844984c377fdb6972320f51a35f4c1566b4c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 10 Apr 2025 00:48:33 +0000 Subject: [PATCH 04/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 233b563..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid options. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=b(R,{dtype:"bool",order:A}),S=new c("uint8",u(l(F),0),R,p(F,0),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,b,c,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),c=h(e),b=o(e),r(d)){if(!t(h(d),c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,c,m(a),b)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 505bb86..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid options. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","Error","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":";;6iGAuDA,SAASA,EAAUC,EAAMC,EAAOC,GAC/B,IAAIC,EACJ,IAAMC,EAAUF,GACf,OAAO,IAAIG,UAAWC,EAAQ,SAAUJ,IAEzC,GAAKK,EAAYL,EAAS,cACzBF,EAAKQ,SAAWN,EAAQM,UAClBC,EAAWT,EAAKQ,WACrB,OAAO,IAAIH,UAAWC,EAAQ,SAAU,WAAYN,EAAKQ,WAG3D,GAAKD,EAAYL,EAAS,QAAW,CAEpC,GADAF,EAAKU,KAAOR,EAAQQ,MACdC,EAAgBX,EAAKU,QAAWE,EAAmBZ,EAAKU,MAC7D,OAAO,IAAIL,UAAWC,EAAQ,2EAA4E,OAAQN,EAAKU,OAGxH,GAAa,QADbP,EAAMU,EAAkBb,EAAKU,KAAMT,EAAM,IAExC,OAAO,IAAIa,WAAYR,EAAQ,uFAAwF,OAAQS,EAAMf,EAAKU,KAAM,OAEjJ,GAAKP,EAAIa,OAASf,EACjB,OAAO,IAAIa,WAAYR,EAAQ,gIAAiIL,EAAOc,EAAMf,EAAKU,KAAM,OAEzLV,EAAKU,KAAOP,CACZ,CACD,OAAO,IACR,CCYA,SAASc,EAAUC,EAAGC,EAAejB,GACpC,IAAIF,EACAoB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeZ,GACpB,MAAM,IAAIb,UAAWC,EAAQ,SAAUY,IAMxC,GAHAS,GADAJ,EAAMQ,EAAUb,IACRF,OAERhB,EAAOgC,EAAc,GAAIC,GACpBC,UAAUlB,OAAS,IACvBK,EAAMtB,EAAUC,EAAM2B,EAAGzB,IAExB,MAAMmB,EAkBR,GAdmB,OAAdrB,EAAKU,OACTV,EAAKU,KAAOyB,EAAQR,IAGrBL,EAAMc,EAAmBT,EAAG3B,EAAKU,MAGjCc,EAAMa,EAAad,EAAKD,GAGxBI,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAIrB,UAAWC,EAAQ,qGAAsGa,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeK,EACxC,CAAC,MAAQH,GACT,MAAM,IAAIqB,MAAO,qHACjB,CACD,KAAM,KAAKC,EAA8BxB,EAAeO,GAGxD,MAAM,IAAIrB,UAAWC,EAAQ,qGAAsGa,IAFnIS,EAAIgB,EAAiBzB,EAAeO,EAAIF,EAAKC,EAG7C,CAiBD,OAfAI,EAAIgB,EAAOrB,EAAK,CACfsB,MAAS,OACTC,MAAStB,IAIVL,EAAO,IAAI4B,EAAa,QAASC,EAAoBC,EAASrB,GAAK,GAAKL,EAAK2B,EAAYtB,EAAG,GAAKuB,EAAWvB,GAAKU,EAAUV,IAG3HwB,EAAqBC,EAAM,CAAEpC,EAAGE,EAAMQ,GAAK5B,EAAKU,MAG3CV,EAAKQ,WACTqB,EAAI0B,EAAkB5B,EAAGE,EAAGP,IAEtBO,CACR,CC3EA,SAAS2B,EAAQtC,EAAGC,EAAeU,EAAG3B,GACrC,IAAIF,EACAqB,EACAI,EACAC,EACAC,EACAC,EAEJ,IAAME,EAAeZ,GACpB,MAAM,IAAIb,UAAWC,EAAQ,SAAUY,IAExC,IAAMY,EAAeD,GACpB,MAAM,IAAIxB,UAAWC,EAAQ,gFAAiFuB,IAK/G,GAHAF,EAAI1B,EAAOiB,GAEXlB,EAAOgC,EAAc,GAAIC,GACpBC,UAAUlB,OAAS,IACvBK,EAAMtB,EAAUC,EAAM2B,EAAGzB,IAExB,MAAMmB,EAWR,GARmB,OAAdrB,EAAKU,OACTV,EAAKU,KAAOyB,EAAQR,IAGrBD,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAIrB,UAAWC,EAAQ,qGAAsGa,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeY,EAAUF,GAClD,CAAC,MAAQR,GACT,MAAM,IAAIqB,MAAO,qHACjB,CACD,KAAM,KAAKC,EAA8BxB,EAAeO,GAGxD,MAAM,IAAIrB,UAAWC,EAAQ,qGAAsGa,IAFnIS,EAAIgB,EAAiBzB,EAAeO,EAAIK,EAAUF,GAAKJ,EAGvD,CAGD,OADA4B,EAAqBC,EAAM,CAAEpC,EAAGW,EAAGD,GAAK5B,EAAKU,MACtCmB,CACR,CC3CA4B,EAAAC,EAAA,SAAAF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 92d49d8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e4e928355bb9c5fd98dd478e926eedfd69544cb0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 10 Apr 2025 00:49:18 +0000 Subject: [PATCH 05/57] 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 | 61 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 105 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 87 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4892 insertions(+), 4830 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -379,7 +376,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -442,13 +439,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a49cde6..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,z){z.exports={dims:null,keepdims:!1}});var c=q(function(jr,T){"use strict";var E=require("@stdlib/assert-is-plain-object"),h=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),S=require("@stdlib/array-base-join"),p=require("@stdlib/string-format");function P(r,e,a){var i;if(!E(a))return new TypeError(p("invalid argument. Options argument must be an object. Value: `%s`.",a));if(h(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(p("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(h(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(p("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(p("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",S(r.dims,",")));if(i.length>e)return new RangeError(p("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",e,S(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),b=require("@stdlib/string-format"),nr=g(),ur=c();function sr(r,e,a){var i,n,o,v,u,t,d,m,l,f,s;if(!k(r))throw new TypeError(b("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),l=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,l,a),o))throw o;if(i.dims===null&&(i.dims=ir(l)),v=U(l,i.dims),t=ar(u,v),m=j(r),d=O(r),k(e)){if(!H(j(e),m))throw new TypeError(b("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{f=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,m))f=rr(e,m,t,d);else throw new TypeError(b("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,0),Z(s),O(s)),J(K,[r,n,f],i.dims),i.keepdims&&(s=Q(l,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),w=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),yr=require("@stdlib/ndarray-base-broadcast-scalar"),fr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),y=require("@stdlib/string-format"),cr=g(),br=c();function wr(r,e,a,i){var n,o,v,u,t,d;if(!w(r))throw new TypeError(y("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!w(a))throw new TypeError(y("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=fr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),w(e)){if(!dr(R(e),u))throw new TypeError(y("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(m){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=yr(e,u,A(a),v);else throw new TypeError(y("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),M=C(),Sr=D();hr(M,"assign",Sr);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 d326d47..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index c22af2a..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,105 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c0ce9f9 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=b(R,{dtype:"bool",order:A}),S=new c("uint8",u(l(F),0),R,p(F,0),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,b,c,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),c=h(e),b=o(e),r(d)){if(!t(h(d),c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,c,m(a),b)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..79a8fea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","Error","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0542b05..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index e114626..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a02af27 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 74115f833b8846dfcab8daae4aadd85ec971d776 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:07:12 +0000 Subject: [PATCH 06/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 049ccc7..0d7afb0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index 4bdff92..10dac9a 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 849cbf1720697d0624387847824122c884b00a99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:09:20 +0000 Subject: [PATCH 07/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c0ce9f9..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=b(R,{dtype:"bool",order:A}),S=new c("uint8",u(l(F),0),R,p(F,0),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,b,c,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),c=h(e),b=o(e),r(d)){if(!t(h(d),c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,c))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,c,m(a),b)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 79a8fea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, 0 ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","Error","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a02af27..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1c429e2f832a465e06feb391707e02dc6d69bf20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 18 Apr 2025 10:09:48 +0000 Subject: [PATCH 08/57] 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 | 64 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 105 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4892 insertions(+), 4836 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -379,7 +376,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -442,13 +439,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index df13b97..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 f77cc15..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACE,KAAQ,KACR,SAAY,EACd,ICHA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAiB,QAAS,iCAAkC,EAAE,WAC9DC,EAAoB,QAAS,oCAAqC,EAClEC,EAAmB,QAAS,mDAAoD,EAChFC,EAAO,QAAS,yBAA0B,EAC1CC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAMC,EAAOC,EAAU,CACzC,IAAIC,EACJ,GAAK,CAACZ,EAAUW,CAAQ,EACvB,OAAO,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE/G,GAAKV,EAAYU,EAAS,UAAW,IACpCF,EAAK,SAAWE,EAAQ,SACnB,CAACT,EAAWO,EAAK,QAAS,GAC9B,OAAO,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAG5H,GAAKR,EAAYU,EAAS,MAAO,EAAI,CAEpC,GADAF,EAAK,KAAOE,EAAQ,KACf,CAACR,EAAgBM,EAAK,IAAK,GAAK,CAACL,EAAmBK,EAAK,IAAK,EAClE,OAAO,IAAI,UAAWF,EAAQ,0EAA2E,OAAQE,EAAK,IAAK,CAAE,EAG9H,GADAG,EAAMP,EAAkBI,EAAK,KAAMC,EAAM,CAAE,EACtCE,IAAQ,KACZ,OAAO,IAAI,WAAYL,EAAQ,uFAAwF,OAAQD,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAEzJ,GAAKG,EAAI,SAAWH,EAAK,KAAK,OAC7B,OAAO,IAAI,MAAOF,EAAQ,wEAAyE,OAAQD,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAErI,GAAKG,EAAI,OAASF,EACjB,OAAO,IAAI,WAAYH,EAAQ,gIAAiIG,EAAOJ,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAEjMA,EAAK,KAAOG,CACb,CACA,OAAO,IACR,CAKAb,EAAO,QAAUS,ICzFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAA+B,QAAS,8DAA+D,EACvGC,EAAmB,QAAS,2DAA4D,EACxFC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAsB,QAAS,4CAA6C,EAC5EC,EAAO,QAAS,+BAAgC,EAChDC,EAAmB,QAAS,wCAAyC,EACrEC,EAAoB,QAAS,uCAAwC,EACrEC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAQ,QAAS,uBAAwB,EACzCC,EAAc,QAAS,2BAA4B,EACnDC,EAAsB,QAAS,4CAA6C,EAC5EC,GAAkB,QAAS,uCAAwC,EACnEC,GAAqB,QAAS,0CAA2C,EACzEC,GAAc,QAAS,iCAAkC,EACzDC,GAAS,QAAS,4BAA6B,EAC/CC,GAAe,QAAS,uBAAwB,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAW,IACXC,GAAW,IAgDf,SAASC,GAAUC,EAAGC,EAAeC,EAAU,CAC9C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACpC,EAAeuB,CAAE,EACtB,MAAM,IAAI,UAAWJ,EAAQ,gFAAiFI,CAAE,CAAE,EAMnH,GAJAO,EAAMzB,EAAUkB,CAAE,EAClBW,EAAIJ,EAAI,OAERJ,EAAOR,GAAc,CAAC,EAAGE,EAAS,EAC7B,UAAU,OAAS,IACvBQ,EAAMP,GAAUK,EAAMQ,EAAGT,CAAQ,EAC5BG,GACJ,MAAMA,EAkBR,GAdKF,EAAK,OAAS,OAClBA,EAAK,KAAOT,GAAQiB,CAAE,GAGvBL,EAAMzB,EAAmB8B,EAAGR,EAAK,IAAK,EAGtCK,EAAMf,GAAac,EAAKD,CAAI,EAG5BI,EAAKvB,EAAUa,CAAE,EACjBS,EAAM1B,EAAUiB,CAAE,EAGbvB,EAAewB,CAAc,EAAI,CACrC,GAAK,CAACzB,EAAkBW,EAAUc,CAAc,EAAGS,CAAG,EACrD,MAAM,IAAI,UAAWd,EAAQ,qGAAsGK,CAAc,CAAE,EAEpJ,GAAI,CACHW,EAAItB,EAAqBW,EAAeO,CAAI,CAC7C,OAAUH,GAAM,CACf,MAAM,IAAI,MAAO,oHAAqH,CACvI,CACD,SAAY9B,EAA8B0B,EAAeS,CAAG,EAC3DE,EAAIrB,GAAiBU,EAAeS,EAAIF,EAAKC,CAAI,MAEjD,OAAM,IAAI,UAAWb,EAAQ,qGAAsGK,CAAc,CAAE,EAGpJ,OAAAY,EAAIzB,EAAOoB,EAAK,CACf,MAAS,OACT,MAASC,CACV,CAAC,EAGDL,EAAO,IAAIf,EAAa,QAASG,GAAoBR,EAAS6B,CAAE,EAAG,CAAE,EAAGL,EAAKvB,EAAY4B,EAAG,EAAM,EAAG3B,EAAW2B,CAAE,EAAG9B,EAAU8B,CAAE,CAAE,EAGnInC,EAAqBC,EAAM,CAAEqB,EAAGI,EAAMQ,CAAE,EAAGT,EAAK,IAAK,EAGhDA,EAAK,WACTU,EAAIjC,EAAkB+B,EAAGE,EAAGP,CAAI,GAE1BO,CACR,CAKAvC,EAAO,QAAUyB,KC1KjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAA+B,QAAS,8DAA+D,EACvGC,GAAmB,QAAS,2DAA4D,EACxFC,EAAgB,QAAS,gCAAiC,EAC1DC,GAAsB,QAAS,4CAA6C,EAC5EC,GAAQ,QAAS,uBAAwB,EACzCC,GAAO,QAAS,+BAAgC,EAChDC,EAAW,QAAS,uBAAwB,EAC5CC,GAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,GAAsB,QAAS,4CAA6C,EAC5EC,GAAkB,QAAS,uCAAwC,EACnEC,GAAe,QAAS,uBAAwB,EAChDC,GAAS,QAAS,4BAA6B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAW,IACXC,GAAW,IAqDf,SAASC,GAAQC,EAAGC,EAAeC,EAAGC,EAAU,CAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWJ,EAAQ,gFAAiFI,CAAE,CAAE,EAEnH,GAAK,CAACf,EAAeiB,CAAE,EACtB,MAAM,IAAI,UAAWN,EAAQ,gFAAiFM,CAAE,CAAE,EAKnH,GAHAM,EAAIrB,GAAOa,CAAE,EAEbI,EAAOV,GAAc,CAAC,EAAGG,EAAS,EAC7B,UAAU,OAAS,IACvBQ,EAAMP,GAAUM,EAAMI,EAAGL,CAAQ,EAC5BE,GACJ,MAAMA,EAWR,GARKD,EAAK,OAAS,OAClBA,EAAK,KAAOT,GAAQa,CAAE,GAGvBD,EAAKhB,EAAUS,CAAE,EACjBM,EAAMhB,GAAUU,CAAE,EAGbf,EAAegB,CAAc,EAAI,CACrC,GAAK,CAACjB,GAAkBO,EAAUU,CAAc,EAAGM,CAAG,EACrD,MAAM,IAAI,UAAWX,EAAQ,qGAAsGK,CAAc,CAAE,EAEpJ,GAAI,CACHQ,EAAIjB,GAAqBS,EAAeZ,EAAUa,CAAE,CAAE,CACvD,OAAUG,EAAM,CACf,MAAM,IAAI,MAAO,oHAAqH,CACvI,CACD,SAAYtB,GAA8BkB,EAAeM,CAAG,EAC3DE,EAAIhB,GAAiBQ,EAAeM,EAAIlB,EAAUa,CAAE,EAAGI,CAAI,MAE3D,OAAM,IAAI,UAAWV,EAAQ,qGAAsGK,CAAc,CAAE,EAGpJ,OAAAf,GAAqBE,GAAM,CAAEY,EAAGE,EAAGO,CAAE,EAAGL,EAAK,IAAK,EAC3CF,CACR,CAKApB,EAAO,QAAUiB,KCvDjB,IAAIW,GAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAS,IAKbF,GAAaC,EAAM,SAAUC,EAAO,EAKpC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index c22af2a..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,105 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..910c0f8 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..487dc06 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d7afb0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 10dac9a..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dfc6f2a --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From f62a9601cf249c9c975b60b316c7e5b5b94a452a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:51:17 +0000 Subject: [PATCH 09/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 049ccc7..0d7afb0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index 4bdff92..10dac9a 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 3e5d223515255a18abb40d4ab6dff1794bbd5f3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:52:49 +0000 Subject: [PATCH 10/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 910c0f8..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 487dc06..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dfc6f2a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e14a9e2f1f2afadf765506e3d5e40b07a833af0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 12 May 2025 00:53:33 +0000 Subject: [PATCH 11/57] 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 | 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 | 64 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 87 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 105 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4892 insertions(+), 4837 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 2d21561..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-12T00:50:30.319Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -379,7 +376,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -442,13 +439,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index df13b97..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 f77cc15..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index c22af2a..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,105 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var xbuf = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var dt = 'float64'; - > var sh = [ 2, 2 ]; - > var sx = [ 2, 1 ]; - > var ox = 0; - > var ord = 'row-major'; - > var x = {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..910c0f8 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..487dc06 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":";;6iGAuDA,SAASA,EAAUC,EAAMC,EAAOC,GAC/B,IAAIC,EACJ,IAAMC,EAAUF,GACf,OAAO,IAAIG,UAAWC,EAAQ,SAAUJ,IAEzC,GAAKK,EAAYL,EAAS,cACzBF,EAAKQ,SAAWN,EAAQM,UAClBC,EAAWT,EAAKQ,WACrB,OAAO,IAAIH,UAAWC,EAAQ,SAAU,WAAYN,EAAKQ,WAG3D,GAAKD,EAAYL,EAAS,QAAW,CAEpC,GADAF,EAAKU,KAAOR,EAAQQ,MACdC,EAAgBX,EAAKU,QAAWE,EAAmBZ,EAAKU,MAC7D,OAAO,IAAIL,UAAWC,EAAQ,0EAA2E,OAAQN,EAAKU,OAGvH,GAAa,QADbP,EAAMU,EAAkBb,EAAKU,KAAMT,EAAM,IAExC,OAAO,IAAIa,WAAYR,EAAQ,uFAAwF,OAAQS,EAAMf,EAAKU,KAAM,OAEjJ,GAAKP,EAAIa,SAAWhB,EAAKU,KAAKM,OAC7B,OAAO,IAAIC,MAAOX,EAAQ,wEAAyE,OAAQS,EAAMf,EAAKU,KAAM,OAE7H,GAAKP,EAAIa,OAASf,EACjB,OAAO,IAAIa,WAAYR,EAAQ,gIAAiIL,EAAOc,EAAMf,EAAKU,KAAM,OAEzLV,EAAKU,KAAOP,CACZ,CACD,OAAO,IACR,CCSA,SAASe,EAAUC,EAAGC,EAAelB,GACpC,IAAIF,EACAqB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAMxC,GAHAS,GADAJ,EAAMQ,EAAUb,IACRH,OAERhB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAkBR,GAdmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBL,EAAMc,EAAmBT,EAAG5B,EAAKU,MAGjCe,EAAMa,EAAad,EAAKD,GAGxBI,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeK,EACxC,CAAC,MAAQH,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIF,EAAKC,EAG7C,CAiBD,OAfAI,EAAIe,EAAOpB,EAAK,CACfqB,MAAS,OACTC,MAASrB,IAIVL,EAAO,IAAI2B,EAAa,QAASC,EAAoBC,EAASpB,GAAK,GAAKL,EAAK0B,EAAYrB,GAAG,GAASsB,EAAWtB,GAAKU,EAAUV,IAG/HuB,EAAqBC,EAAM,CAAEnC,EAAGE,EAAMQ,GAAK7B,EAAKU,MAG3CV,EAAKQ,WACTsB,EAAIyB,EAAkB3B,EAAGE,EAAGP,IAEtBO,CACR,CC3EA,SAAS0B,EAAQrC,EAAGC,EAAeU,EAAG5B,GACrC,IAAIF,EACAsB,EACAI,EACAC,EACAC,EACAC,EAEJ,IAAME,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAExC,IAAMY,EAAeD,GACpB,MAAM,IAAIzB,UAAWC,EAAQ,gFAAiFwB,IAK/G,GAHAF,EAAI3B,EAAOkB,GAEXnB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAWR,GARmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBD,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeY,EAAUF,GAClD,CAAC,MAAQR,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIK,EAAUF,GAAKJ,EAGvD,CAGD,OADA2B,EAAqBC,EAAM,CAAEnC,EAAGW,EAAGD,GAAK7B,EAAKU,MACtCoB,CACR,CC3CA2B,EAAAC,EAAA,SAAAF"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d7afb0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 10dac9a..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dfc6f2a --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From f60c8b082b25f24f9ac3cc850005e95e4af5a678 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 May 2025 21:03:25 +0000 Subject: [PATCH 12/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 049ccc7..0d7afb0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index 4bdff92..10dac9a 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From b2c218b5b208489e8356c32573fcb844424e4b35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 May 2025 21:03:48 +0000 Subject: [PATCH 13/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 910c0f8..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 487dc06..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dfc6f2a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b5c1ac540395cd39ccb1b67b67003376ba60177e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 May 2025 21:04:37 +0000 Subject: [PATCH 14/57] 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 | 65 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4820 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index df13b97..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 f77cc15..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..910c0f8 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..487dc06 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d7afb0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 10dac9a..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dfc6f2a --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 14dc958453650253595ffd8600eeea5ada0e2a50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Sep 2025 05:47:58 +0000 Subject: [PATCH 15/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 049ccc7..0d7afb0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 50e3811416e9ecd36bfd3bacdc46c8e240d70b46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Sep 2025 05:48:40 +0000 Subject: [PATCH 16/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 910c0f8..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 487dc06..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dfc6f2a..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 62c918c65a1505f688430c90b9b55751dcb2bd55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Sep 2025 05:49:24 +0000 Subject: [PATCH 17/57] 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 | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 68 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4828 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 0eb8f58..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index f8e1740..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',' )+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b783572..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 7b719f4..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACE,KAAQ,KACR,SAAY,EACd,ICHA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAiB,QAAS,iCAAkC,EAAE,WAC9DC,EAAoB,QAAS,oCAAqC,EAClEC,EAAmB,QAAS,mDAAoD,EAChFC,EAAO,QAAS,yBAA0B,EAC1CC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAMC,EAAOC,EAAU,CACzC,IAAIC,EACJ,GAAK,CAACZ,EAAUW,CAAQ,EACvB,OAAO,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE/G,GAAKV,EAAYU,EAAS,UAAW,IACpCF,EAAK,SAAWE,EAAQ,SACnB,CAACT,EAAWO,EAAK,QAAS,GAC9B,OAAO,IAAI,UAAWF,EAAQ,+DAAgE,WAAYE,EAAK,QAAS,CAAE,EAG5H,GAAKR,EAAYU,EAAS,MAAO,EAAI,CAEpC,GADAF,EAAK,KAAOE,EAAQ,KACf,CAACR,EAAgBM,EAAK,IAAK,GAAK,CAACL,EAAmBK,EAAK,IAAK,EAClE,OAAO,IAAI,UAAWF,EAAQ,0EAA2E,OAAQE,EAAK,IAAK,CAAE,EAG9H,GADAG,EAAMP,EAAkBI,EAAK,KAAMC,EAAM,CAAE,EACtCE,IAAQ,KACZ,OAAO,IAAI,WAAYL,EAAQ,uFAAwF,OAAQD,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAEzJ,GAAKG,EAAI,SAAWH,EAAK,KAAK,OAC7B,OAAO,IAAI,MAAOF,EAAQ,wEAAyE,OAAQD,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAErI,GAAKG,EAAI,OAASF,EACjB,OAAO,IAAI,WAAYH,EAAQ,gIAAiI,OAAQG,EAAOJ,EAAMG,EAAK,KAAM,GAAI,CAAE,CAAE,EAEzMA,EAAK,KAAOG,CACb,CACA,OAAO,IACR,CAKAb,EAAO,QAAUS,ICzFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAA+B,QAAS,8DAA+D,EACvGC,EAAmB,QAAS,2DAA4D,EACxFC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAsB,QAAS,4CAA6C,EAC5EC,EAAO,QAAS,+BAAgC,EAChDC,EAAmB,QAAS,wCAAyC,EACrEC,EAAoB,QAAS,uCAAwC,EACrEC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,4BAA6B,EACjDC,EAAU,QAAS,kCAAmC,EACtDC,EAAa,QAAS,8BAA+B,EACrDC,EAAY,QAAS,6BAA8B,EACnDC,EAAW,QAAS,4BAA6B,EACjDC,EAAQ,QAAS,uBAAwB,EACzCC,EAAc,QAAS,2BAA4B,EACnDC,EAAsB,QAAS,4CAA6C,EAC5EC,GAAkB,QAAS,uCAAwC,EACnEC,GAAqB,QAAS,0CAA2C,EACzEC,GAAc,QAAS,iCAAkC,EACzDC,GAAS,QAAS,4BAA6B,EAC/CC,GAAe,QAAS,uBAAwB,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAW,IACXC,GAAW,IAgDf,SAASC,GAAUC,EAAGC,EAAeC,EAAU,CAC9C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACpC,EAAeuB,CAAE,EACtB,MAAM,IAAI,UAAWJ,EAAQ,gFAAiFI,CAAE,CAAE,EAMnH,GAJAO,EAAMzB,EAAUkB,CAAE,EAClBW,EAAIJ,EAAI,OAERJ,EAAOR,GAAc,CAAC,EAAGE,EAAS,EAC7B,UAAU,OAAS,IACvBQ,EAAMP,GAAUK,EAAMQ,EAAGT,CAAQ,EAC5BG,GACJ,MAAMA,EAkBR,GAdKF,EAAK,OAAS,OAClBA,EAAK,KAAOT,GAAQiB,CAAE,GAGvBL,EAAMzB,EAAmB8B,EAAGR,EAAK,IAAK,EAGtCK,EAAMf,GAAac,EAAKD,CAAI,EAG5BI,EAAKvB,EAAUa,CAAE,EACjBS,EAAM1B,EAAUiB,CAAE,EAGbvB,EAAewB,CAAc,EAAI,CACrC,GAAK,CAACzB,EAAkBW,EAAUc,CAAc,EAAGS,CAAG,EACrD,MAAM,IAAI,UAAWd,EAAQ,qGAAsGK,CAAc,CAAE,EAEpJ,GAAI,CACHW,EAAItB,EAAqBW,EAAeO,CAAI,CAC7C,OAAUH,GAAM,CACf,MAAM,IAAI,MAAO,oHAAqH,CACvI,CACD,SAAY9B,EAA8B0B,EAAeS,CAAG,EAC3DE,EAAIrB,GAAiBU,EAAeS,EAAIF,EAAKC,CAAI,MAEjD,OAAM,IAAI,UAAWb,EAAQ,qGAAsGK,CAAc,CAAE,EAGpJ,OAAAY,EAAIzB,EAAOoB,EAAK,CACf,MAAS,OACT,MAASC,CACV,CAAC,EAGDL,EAAO,IAAIf,EAAa,QAASG,GAAoBR,EAAS6B,CAAE,EAAG,CAAE,EAAGL,EAAKvB,EAAY4B,EAAG,EAAM,EAAG3B,EAAW2B,CAAE,EAAG9B,EAAU8B,CAAE,CAAE,EAGnInC,EAAqBC,EAAM,CAAEqB,EAAGI,EAAMQ,CAAE,EAAGT,EAAK,IAAK,EAGhDA,EAAK,WACTU,EAAIjC,EAAkB+B,EAAGE,EAAGP,CAAI,GAE1BO,CACR,CAKAvC,EAAO,QAAUyB,KC1KjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAA+B,QAAS,8DAA+D,EACvGC,GAAmB,QAAS,2DAA4D,EACxFC,EAAgB,QAAS,gCAAiC,EAC1DC,GAAsB,QAAS,4CAA6C,EAC5EC,GAAQ,QAAS,uBAAwB,EACzCC,GAAO,QAAS,+BAAgC,EAChDC,EAAW,QAAS,uBAAwB,EAC5CC,GAAW,QAAS,4BAA6B,EACjDC,EAAW,QAAS,4BAA6B,EACjDC,GAAsB,QAAS,4CAA6C,EAC5EC,GAAkB,QAAS,uCAAwC,EACnEC,GAAe,QAAS,uBAAwB,EAChDC,GAAS,QAAS,4BAA6B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAW,IACXC,GAAW,IAqDf,SAASC,GAAQC,EAAGC,EAAeC,EAAGC,EAAU,CAC/C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACxB,EAAee,CAAE,EACtB,MAAM,IAAI,UAAWJ,EAAQ,gFAAiFI,CAAE,CAAE,EAEnH,GAAK,CAACf,EAAeiB,CAAE,EACtB,MAAM,IAAI,UAAWN,EAAQ,gFAAiFM,CAAE,CAAE,EAKnH,GAHAM,EAAIrB,GAAOa,CAAE,EAEbI,EAAOV,GAAc,CAAC,EAAGG,EAAS,EAC7B,UAAU,OAAS,IACvBQ,EAAMP,GAAUM,EAAMI,EAAGL,CAAQ,EAC5BE,GACJ,MAAMA,EAWR,GARKD,EAAK,OAAS,OAClBA,EAAK,KAAOT,GAAQa,CAAE,GAGvBD,EAAKhB,EAAUS,CAAE,EACjBM,EAAMhB,GAAUU,CAAE,EAGbf,EAAegB,CAAc,EAAI,CACrC,GAAK,CAACjB,GAAkBO,EAAUU,CAAc,EAAGM,CAAG,EACrD,MAAM,IAAI,UAAWX,EAAQ,qGAAsGK,CAAc,CAAE,EAEpJ,GAAI,CACHQ,EAAIjB,GAAqBS,EAAeZ,EAAUa,CAAE,CAAE,CACvD,OAAUG,EAAM,CACf,MAAM,IAAI,MAAO,oHAAqH,CACvI,CACD,SAAYtB,GAA8BkB,EAAeM,CAAG,EAC3DE,EAAIhB,GAAiBQ,EAAeM,EAAIlB,EAAUa,CAAE,EAAGI,CAAI,MAE3D,OAAM,IAAI,UAAWV,EAAQ,qGAAsGK,CAAc,CAAE,EAGpJ,OAAAf,GAAqBE,GAAM,CAAEY,EAAGE,EAAGO,CAAE,EAAGL,EAAK,IAAK,EAC3CF,CACR,CAKApB,EAAO,QAAUiB,KCvDjB,IAAIW,GAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAS,IAKbF,GAAaC,EAAM,SAAUC,EAAO,EAKpC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e034deb --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs";var A={dims:null,keepdims:!1};function B(s,e,t){var r;if(!E(t))return new TypeError(R("null2V",t));if(k(t,"keepdims")&&(s.keepdims=t.keepdims,!T(s.keepdims)))return new TypeError(R("null2o","keepdims",s.keepdims));if(k(t,"dims")){if(s.dims=t.dims,!S(s.dims)&&!V(s.dims))return new TypeError(R("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",s.dims));if(null===(r=O(s.dims,e-1)))return new RangeError(R("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(s.dims,",")));if(r.length!==s.dims.length)return new Error(R("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(s.dims,",")));if(r.length>e)return new RangeError(R("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,z(s.dims,",")));s.dims=r}return null}function C(s,E,k){var T,S,V,O,z,R,q,N,C,D,F;if(!r(s))throw new TypeError(w("null5t",s));if(C=(z=a(s)).length,T=x({},A),arguments.length>2&&(V=B(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=m(C,T.dims),R=y(z,O),N=h(s),q=o(s),r(E)){if(!t(h(E),N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(E,N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=u(E,N,R,q)}return F=c(R,{dtype:"bool",order:q}),S=new b("uint8",v(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[s,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function D(s,d,m,l){var p,j,c,b,v,y;if(!r(s))throw new TypeError(w("null5t",s));if(!r(m))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",m));if(v=q(s),p=x({},A),arguments.length>3&&(j=B(p,v,l)))throw j;if(null===p.dims&&(p.dims=N(v)),b=h(s),c=o(s),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,a(m))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=u(d,b,a(m),c)}return i(n,[s,m,y],p.dims),m}s(C,"assign",D);export{D as assign,C as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d5c99ef --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d7afb0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fcedfa --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From a92eeb99643581dde2052c241a98cdd575c6ef21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Nov 2025 04:29:13 +0000 Subject: [PATCH 18/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 049ccc7..0d7afb0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From c9f97b5bccc830b1be1c1c0b79c8b956ccdfef60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Nov 2025 04:30:15 +0000 Subject: [PATCH 19/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e034deb..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs";var A={dims:null,keepdims:!1};function B(s,e,t){var r;if(!E(t))return new TypeError(R("null2V",t));if(k(t,"keepdims")&&(s.keepdims=t.keepdims,!T(s.keepdims)))return new TypeError(R("null2o","keepdims",s.keepdims));if(k(t,"dims")){if(s.dims=t.dims,!S(s.dims)&&!V(s.dims))return new TypeError(R("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",s.dims));if(null===(r=O(s.dims,e-1)))return new RangeError(R("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(s.dims,",")));if(r.length!==s.dims.length)return new Error(R("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(s.dims,",")));if(r.length>e)return new RangeError(R("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,z(s.dims,",")));s.dims=r}return null}function C(s,E,k){var T,S,V,O,z,R,q,N,C,D,F;if(!r(s))throw new TypeError(w("null5t",s));if(C=(z=a(s)).length,T=x({},A),arguments.length>2&&(V=B(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=m(C,T.dims),R=y(z,O),N=h(s),q=o(s),r(E)){if(!t(h(E),N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(E,N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=u(E,N,R,q)}return F=c(R,{dtype:"bool",order:q}),S=new b("uint8",v(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[s,S,D],T.dims),T.keepdims&&(F=d(C,F,O)),F}function D(s,d,m,l){var p,j,c,b,v,y;if(!r(s))throw new TypeError(w("null5t",s));if(!r(m))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",m));if(v=q(s),p=x({},A),arguments.length>3&&(j=B(p,v,l)))throw j;if(null===p.dims&&(p.dims=N(v)),b=h(s),c=o(s),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,a(m))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=u(d,b,a(m),c)}return i(n,[s,m,y],p.dims),m}s(C,"assign",D);export{D as assign,C as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d5c99ef..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fcedfa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ccf6672f1898b856d35654b5edf57829d99adb8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Nov 2025 04:31:09 +0000 Subject: [PATCH 20/57] 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 | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 69 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4829 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b783572..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 7b719f4..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2219ae3 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";var B={dims:null,keepdims:!1};function C(s,e,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(s.keepdims=t.keepdims,!T(s.keepdims)))return new TypeError(w("null2o","keepdims",s.keepdims));if(k(t,"dims")){if(s.dims=t.dims,!S(s.dims)&&!V(s.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",s.dims));if(null===(r=O(s.dims,e-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(s.dims,",")));if(r.length!==s.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(s.dims,",")));if(r.length>e)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,z(s.dims,",")));s.dims=r}return null}function D(s,E,k){var T,S,V,O,z,R,q,N,A,D,F;if(!r(s))throw new TypeError(w("null5t",s));if(A=(z=m(s)).length,T=x({},B),arguments.length>2&&(V=C(T,A,k)))throw V;if(null===T.dims&&(T.dims=v(A)),O=a(A,T.dims),R=g(z,O),N=h(s),q=o(s),r(E)){if(!t(h(E),N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(E,N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=y(E,N,R,q)}return F=c(R,{dtype:"bool",order:q}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[s,S,D],T.dims),T.keepdims&&(F=d(A,F,O)),F}function F(s,t,r,d){var a,m,l,p,j,c;if(!q(s))throw new TypeError(w("null5t",s));if(!q(r))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",r));if(j=N(s),a=x({},B),arguments.length>3&&(m=C(a,j,d)))throw m;if(null===a.dims&&(a.dims=v(j)),p=h(s),l=o(s),q(t)){if(!R(h(t),p))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",t));try{c=f(t,A(r))}catch(m){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(t,p))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",t));c=y(t,p,A(r),l)}return i(n,[s,r,c],a.dims),r}s(D,"assign",F);export{F as assign,D as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7ddd457 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":";;isGAuDA,SAASA,EAAUC,EAAMC,EAAOC,GAC/B,IAAIC,EACJ,IAAMC,EAAUF,GACf,OAAO,IAAIG,UAAWC,EAAQ,SAAUJ,IAEzC,GAAKK,EAAYL,EAAS,cACzBF,EAAKQ,SAAWN,EAAQM,UAClBC,EAAWT,EAAKQ,WACrB,OAAO,IAAIH,UAAWC,EAAQ,SAAU,WAAYN,EAAKQ,WAG3D,GAAKD,EAAYL,EAAS,QAAW,CAEpC,GADAF,EAAKU,KAAOR,EAAQQ,MACdC,EAAgBX,EAAKU,QAAWE,EAAmBZ,EAAKU,MAC7D,OAAO,IAAIL,UAAWC,EAAQ,0EAA2E,OAAQN,EAAKU,OAGvH,GAAa,QADbP,EAAMU,EAAkBb,EAAKU,KAAMT,EAAM,IAExC,OAAO,IAAIa,WAAYR,EAAQ,uFAAwF,OAAQS,EAAMf,EAAKU,KAAM,OAEjJ,GAAKP,EAAIa,SAAWhB,EAAKU,KAAKM,OAC7B,OAAO,IAAIC,MAAOX,EAAQ,wEAAyE,OAAQS,EAAMf,EAAKU,KAAM,OAE7H,GAAKP,EAAIa,OAASf,EACjB,OAAO,IAAIa,WAAYR,EAAQ,gIAAiI,OAAQL,EAAOc,EAAMf,EAAKU,KAAM,OAEjMV,EAAKU,KAAOP,CACZ,CACD,OAAO,IACR,CCSA,SAASe,EAAUC,EAAGC,EAAelB,GACpC,IAAIF,EACAqB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAMxC,GAHAS,GADAJ,EAAMQ,EAAUb,IACRH,OAERhB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAkBR,GAdmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBL,EAAMc,EAAmBT,EAAG5B,EAAKU,MAGjCe,EAAMa,EAAad,EAAKD,GAGxBI,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeK,EACxC,CAAC,MAAQH,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIF,EAAKC,EAG7C,CAiBD,OAfAI,EAAIe,EAAOpB,EAAK,CACfqB,MAAS,OACTC,MAASrB,IAIVL,EAAO,IAAI2B,EAAa,QAASC,EAAoBC,EAASpB,GAAK,GAAKL,EAAK0B,EAAYrB,GAAG,GAASsB,EAAWtB,GAAKU,EAAUV,IAG/HuB,EAAqBC,EAAM,CAAEnC,EAAGE,EAAMQ,GAAK7B,EAAKU,MAG3CV,EAAKQ,WACTsB,EAAIyB,EAAkB3B,EAAGE,EAAGP,IAEtBO,CACR,CC3EA,SAAS0B,EAAQrC,EAAGC,EAAeU,EAAG5B,GACrC,IAAIF,EACAsB,EACAI,EACAC,EACAC,EACAC,EAEJ,IAAME,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAExC,IAAMY,EAAeD,GACpB,MAAM,IAAIzB,UAAWC,EAAQ,gFAAiFwB,IAK/G,GAHAF,EAAI3B,EAAOkB,GAEXnB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAWR,GARmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBD,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeY,EAAUF,GAClD,CAAC,MAAQR,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIK,EAAUF,GAAKJ,EAGvD,CAGD,OADA2B,EAAqBC,EAAM,CAAEnC,EAAGW,EAAGD,GAAK7B,EAAKU,MACtCoB,CACR,CC3CA2B,EAAAC,EAAA,SAAAF"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d7afb0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..53d0cab --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 88bde5fff4d329adfc90d4fa0db67a55fa03dbc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Dec 2025 05:42:35 +0000 Subject: [PATCH 21/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 6c17512..ac90d7f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 0dfff041218805c322e992fb0cf7325c55a3d693 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Dec 2025 05:44:02 +0000 Subject: [PATCH 22/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2219ae3..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@esm/index.mjs";import q from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import N from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@esm/index.mjs";import A from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";var B={dims:null,keepdims:!1};function C(s,e,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(s.keepdims=t.keepdims,!T(s.keepdims)))return new TypeError(w("null2o","keepdims",s.keepdims));if(k(t,"dims")){if(s.dims=t.dims,!S(s.dims)&&!V(s.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",s.dims));if(null===(r=O(s.dims,e-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(s.dims,",")));if(r.length!==s.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(s.dims,",")));if(r.length>e)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,z(s.dims,",")));s.dims=r}return null}function D(s,E,k){var T,S,V,O,z,R,q,N,A,D,F;if(!r(s))throw new TypeError(w("null5t",s));if(A=(z=m(s)).length,T=x({},B),arguments.length>2&&(V=C(T,A,k)))throw V;if(null===T.dims&&(T.dims=v(A)),O=a(A,T.dims),R=g(z,O),N=h(s),q=o(s),r(E)){if(!t(h(E),N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(E,N))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=y(E,N,R,q)}return F=c(R,{dtype:"bool",order:q}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[s,S,D],T.dims),T.keepdims&&(F=d(A,F,O)),F}function F(s,t,r,d){var a,m,l,p,j,c;if(!q(s))throw new TypeError(w("null5t",s));if(!q(r))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",r));if(j=N(s),a=x({},B),arguments.length>3&&(m=C(a,j,d)))throw m;if(null===a.dims&&(a.dims=v(j)),p=h(s),l=o(s),q(t)){if(!R(h(t),p))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",t));try{c=f(t,A(r))}catch(m){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!e(t,p))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",t));c=y(t,p,A(r),l)}return i(n,[s,r,c],a.dims),r}s(D,"assign",F);export{F as assign,D as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7ddd457..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 53d0cab..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b45bd9adcc35309d24158acca2f39f03fc090190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Dec 2025 05:44:46 +0000 Subject: [PATCH 23/57] 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 | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 71 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4831 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..55e0668 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..772a591 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index ac90d7f..7887907 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "github:stdlib-js/array-base-indices-complement#main", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.2", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.2.2", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "github:stdlib-js/ndarray-base-includes#main", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "github:stdlib-js/ndarray-base-spread-dimensions#main", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "github:stdlib-js/ndarray-base-to-unique-normalized-indices#main", - "@stdlib/ndarray-base-unary-reduce-subarray": "github:stdlib-js/ndarray-base-unary-reduce-subarray#main", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", @@ -117,7 +27,6 @@ "reduce", "reduction" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fbef40e --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 1a3cfe8a62321f8cd25bde979fe170bd9d43f25f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:52:15 +0000 Subject: [PATCH 24/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index b093787..33b04e3 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^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" From 385486a0bf28e5ce83298e8f6b71dbf5a9bac711 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:54:22 +0000 Subject: [PATCH 25/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 55e0668..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.2-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=f(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=v(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=f(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=v(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 772a591..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fbef40e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e778b9d63f7809af4fad90bcd7e1b3d5b26b6716 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:54:52 +0000 Subject: [PATCH 26/57] 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 | 71 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4930 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..de7f907 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.3-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.0-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e594995 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 33b04e3..d7e3cf6 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.0", - "@stdlib/array-base-join": "^0.1.1", - "@stdlib/array-base-take-indexed": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/assert-is-empty-collection": "^0.2.3", - "@stdlib/assert-is-integer-array": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.0", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "github:stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible#main", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.2", - "@stdlib/ndarray-base-ctor": "^0.2.2", - "@stdlib/ndarray-base-data-buffer": "^0.2.2", - "@stdlib/ndarray-base-dtype": "^0.2.2", - "@stdlib/ndarray-base-includes": "^0.1.0", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.3", - "@stdlib/ndarray-base-offset": "^0.2.2", - "@stdlib/ndarray-base-order": "^0.2.2", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.0", - "@stdlib/ndarray-base-strides": "^0.2.2", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.0", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.0", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-ndims": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/object-assign": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/math-base-special-sqrt": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-fill-by": "github:stdlib-js/ndarray-fill-by#main", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "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", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a9c47d --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 4f28f1140f575474e5307417a93ad48fb633f032 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:20:08 +0000 Subject: [PATCH 27/57] 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 d6eaca2..553ba88 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; ``` #### includes( x, searchElement\[, options] ) @@ -221,7 +221,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import fillBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-fill-by@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; var x = zeros( [ 2, 4, 5 ], { 'dtype': 'float64' From 7821cc804e22db1314dacae5c534611ae17019e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:20:09 +0000 Subject: [PATCH 28/57] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 553ba88..c742f6b 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@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-includes/tags). For example, + ```javascript import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0. You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; ``` #### includes( x, searchElement\[, options] ) @@ -221,7 +226,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import fillBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-fill-by@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.0-esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; var x = zeros( [ 2, 4, 5 ], { 'dtype': 'float64' From 6555a9cdd3f4874a562e38b30f8acdfa0248fc30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:29:43 +0000 Subject: [PATCH 29/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index edb1f1d..7d50fda 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From b385ddb9ff7179b1272e746312f9cc30743ba83c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:24:22 +0000 Subject: [PATCH 30/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index de7f907..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.0-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.2-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.1-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.2-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.3-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.0-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.1-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.2-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e594995..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a9c47d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e5b9626caaec80ad5ca0597fd0c14b34ec7e00ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:24:50 +0000 Subject: [PATCH 31/57] 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 | 81 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4933 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..40cd9fa --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 7d50fda..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.3", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.0", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fe47857 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 6748813a6eb82b9101f7edf60c8f50b7a20ea81b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:52:34 +0000 Subject: [PATCH 32/57] 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 cdf92c4..d362ab7 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; ``` #### includes( x, searchElement\[, options] ) @@ -221,7 +221,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import fillBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-fill-by@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; var x = zeros( [ 2, 4, 5 ], { 'dtype': 'float64' From 9a25dbf6862c7afab8889a5d32d893991bb57dd5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:52:35 +0000 Subject: [PATCH 33/57] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d362ab7..e02eb4b 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@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-includes/tags). For example, + ```javascript import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0. You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; ``` #### includes( x, searchElement\[, options] ) @@ -221,7 +226,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import fillBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-fill-by@esm/index.mjs'; import zeros from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-zeros@esm/index.mjs'; -import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@v0.1.1-esm/index.mjs'; +import includes from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-includes@esm/index.mjs'; var x = zeros( [ 2, 4, 5 ], { 'dtype': 'float64' From d25a1fac5d99b9ccf5c0997b0873c764eda4482b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:52:38 +0000 Subject: [PATCH 34/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 4e1b1dd..b3458c8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From d160714e6a5750f5d298963349b573d54e97832d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 02:38:49 +0000 Subject: [PATCH 35/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 40cd9fa..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fe47857..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e245959eaf86b56aeafa1e8d0ecda39794926651 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 02:39:28 +0000 Subject: [PATCH 36/57] 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 | 81 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 4934 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 46c105c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T01:34:36.063Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index b3458c8..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 86011eef819a0823882e446c076c4e1037453bb2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:26:54 +0000 Subject: [PATCH 37/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 4e1b1dd..b3458c8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From a89fc8d02ceb71308b14b1d2da0a1ff3867588fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 05:05:56 +0000 Subject: [PATCH 38/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d6fbada00358a56716446e5fd16dfb3b60fcbb49 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 05:06:31 +0000 Subject: [PATCH 39/57] 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 | 81 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 137 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 4934 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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/.keepalive b/.github/.keepalive deleted file mode 100644 index d278e77..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T02:29:33.918Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index edd62c6..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index a1b28fd..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( pkg+':ndims='+sh.length+',len='+len+',shape=['+sh.join(',')+'],xorder='+ord+',xtype='+t1+',dims=['+dims.join(',')+']', f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index b3458c8..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 19d9ed25ace964e9eb4ccba270a781306c0abc52 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Mar 2026 02:19:16 +0000 Subject: [PATCH 40/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 4e1b1dd..b3458c8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From 258931221ac54b2b4272a693aa838de3901c3b80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Mar 2026 02:19:43 +0000 Subject: [PATCH 41/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2f0c813e1b37b5e849b98c32e96078c447f3bf00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 22 Mar 2026 02:20:09 +0000 Subject: [PATCH 42/57] 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 | 115 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 4979 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index b3458c8..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From cc084e45d37b0a737551fc7c1276004146c0f45b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:35:35 +0000 Subject: [PATCH 43/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 4e1b1dd..b3458c8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From 7043ed44a801771d652193227aa5b1854e942e46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:59:51 +0000 Subject: [PATCH 44/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 13e3a5efa388e8a59a26aefd801341548272944a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 04:00:23 +0000 Subject: [PATCH 45/57] 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 | 115 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 4980 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 ac75bbc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-10T03:27:58.703Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index b3458c8..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 284f25a8afa9329c16df43c37d83d2693f229269 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:39:47 +0000 Subject: [PATCH 46/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 4e1b1dd..b3458c8 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From e65c1e8b22a3dec7452e370e5862f268f917cbf5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:56:59 +0000 Subject: [PATCH 47/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2f09ae18209cf74f33a99429bde21b514a0a566a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:57:26 +0000 Subject: [PATCH 48/57] 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 | 115 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 4998 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 0feab47..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-21T03:33:48.280Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6c9cedf..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 bd14fcc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index db0363e..0b2dae6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index b3458c8..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 06bea90c7ce3e76b151bd41c0f9daeed74eb06e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 02:06:12 +0000 Subject: [PATCH 49/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 5f19daf..aa7ae81 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From 1cf9b0025ffedb792711b9f94663dc0ff7610f2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 02:14:20 +0000 Subject: [PATCH 50/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 0b2dae6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b5a78c57f9ae8f97b773eeed7a84d490efa8f215 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jun 2026 02:15:00 +0000 Subject: [PATCH 51/57] 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 | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 47 files changed, 4887 insertions(+), 5000 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a7f7da2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 c222237..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f4ddce6..ad24b59 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aa7ae81..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 5b9c27bcd7c0807b1d1beb79a6fce1f7cf6e7cb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:46:06 +0000 Subject: [PATCH 52/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 5f19daf..aa7ae81 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From 2568402d9b3c57e201a69082842644032886a7c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 04:02:38 +0000 Subject: [PATCH 53/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 ad24b59..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 52d4b23f085c960e57202b119b46fd4b282a3a6d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 04:03:17 +0000 Subject: [PATCH 54/57] 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 | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 5001 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 67dc7f9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-01T03:39:47.050Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a7f7da2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 c222237..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f4ddce6..ad24b59 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aa7ae81..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -}); From 67819282561abf97f5ee80f3bca54700674e63fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 20 Aug 2026 03:13:34 +0000 Subject: [PATCH 55/57] Transform error messages --- lib/assign.js | 4 ++-- lib/main.js | 4 ++-- lib/validate.js | 6 +++--- package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/assign.js b/lib/assign.js index 42a2d90..d3aafba 100644 --- a/lib/assign.js +++ b/lib/assign.js @@ -33,7 +33,7 @@ var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); var objectAssign = require( '@stdlib/object-assign' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -97,7 +97,7 @@ function assign( x, searchElement, y, options ) { var v; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } if ( !isndarrayLike( y ) ) { throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); diff --git a/lib/main.js b/lib/main.js index 8131a8e..4a2b4b0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var takeIndexed = require( '@stdlib/array-base-take-indexed' ); var zeroTo = require( '@stdlib/array-base-zero-to' ); var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var defaults = require( './defaults.json' ); var validate = require( './validate.js' ); @@ -105,7 +105,7 @@ function includes( x, searchElement, options ) { var y; if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) ); + throw new TypeError( format( 'null5t', x ) ); } shx = getShape( x ); N = shx.length; diff --git a/lib/validate.js b/lib/validate.js index df22202..975bdc9 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -27,7 +27,7 @@ var isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,12 +56,12 @@ var format = require( '@stdlib/string-format' ); function validate( opts, ndims, options ) { var tmp; 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, 'keepdims' ) ) { opts.keepdims = options.keepdims; if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) ); + return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); } } if ( hasOwnProp( options, 'dims' ) ) { diff --git a/package.json b/package.json index 5f19daf..aa7ae81 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@stdlib/ndarray-shape": "^0.2.3", "@stdlib/object-assign": "^0.2.3", "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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" From 0f9b907b65c73297e6b695d0117881c039ba3487 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 20 Aug 2026 03:38:13 +0000 Subject: [PATCH 56/57] Remove files --- index.d.ts | 206 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5053 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 ad24b59..0000000 --- a/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, boolndarray } from '@stdlib/types/ndarray'; - -/** -* Base options. -*/ -interface BaseOptions { - /** - * List of dimensions over which to perform the reduction. - */ - dims?: ArrayLike; -} - -/** -* Options. -*/ -interface Options extends BaseOptions { - /** - * Boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions. Default: `false`. - */ - keepdims?: boolean; -} - -/** -* Interface describing `includes`. -*/ -interface Includes { - /** - * Tests whether an ndarray contains a specified value along one or more dimensions. - * - * @param x - input ndarray - * @param searchElement - search element - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var sh = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); - * - * // Perform reduction: - * var out = includes( x, 6.0 ); - * // returns - * - * var v = out.get(); - * // returns true - */ - ( x: ndarray, searchElement: ndarray | unknown, options?: Options ): boolndarray; - - /** - * Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. - * - * @param x - input ndarray - * @param searchElement - search element - * @param y - output ndarray - * @param options - function options - * @param options.dims - list of dimensions over which to perform a reduction - * @returns output ndarray - * - * @example - * var Float64Array = require( '@stdlib/array-float64' ); - * var ndarray = require( '@stdlib/ndarray-ctor' ); - * var empty = require( '@stdlib/ndarray-empty' ); - * - * // Create a data buffer: - * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); - * - * // Define the shape of the input array: - * var shape = [ 3, 1, 2 ]; - * - * // Define the array strides: - * var sx = [ 4, 4, 1 ]; - * - * // Define the index offset: - * var ox = 1; - * - * // Create an input ndarray: - * var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); - * - * // Create an output ndarray: - * var y = empty( [], { - * 'dtype': 'bool' - * }); - * - * // Perform reduction: - * var out = includes.assign( x, 6.0, y ); - * // returns - * - * var v = out.get(); - * // returns true - */ - assign( x: ndarray, searchElement: ndarray | unknown, y: T, options?: BaseOptions ): T; -} - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param x - input ndarray -* @param searchElement - search element -* @param options - function options -* @param options.dims - list of dimensions over which to perform a reduction -* @param options.keepdims - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions (default: false) -* @returns output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -declare var includes: Includes; - - -// EXPORTS // - -export = includes; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 727292b..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 29ee4ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ebc8aa2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2013c8c388c1e51c602ae91aefd57bfec6e15d82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 20 Aug 2026 03:38:41 +0000 Subject: [PATCH 57/57] 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 | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 77 +- SECURITY.md | 5 - benchmark/benchmark.1d.js | 138 - benchmark/benchmark.2d.js | 151 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 93 - docs/types/test.ts | 199 - examples/index.js | 84 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 144 - lib/defaults.json | 4 - lib/index.js | 103 - lib/main.js | 171 - lib/validate.js | 90 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 39 - 48 files changed, 4887 insertions(+), 5002 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.1d.js delete mode 100644 benchmark/benchmark.2d.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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/defaults.json 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 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 2cd2345..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-20T03:06:52.289Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 879d78b..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/includes) 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 b188b3a..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/includes) 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 7625fb7..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: '10 22 * * 2' - - # 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 + + ```
@@ -309,7 +306,7 @@ console.log( ndarray2array( y ) ); ## 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]. @@ -372,13 +369,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-includes/main/LICENSE -[@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/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts +[@stdlib/ndarray/mostly-safe-casts]: https://github.com/stdlib-js/ndarray-mostly-safe-casts/tree/esm -[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes +[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/ndarray-base-broadcast-shapes/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.1d.js b/benchmark/benchmark.1d.js deleted file mode 100644 index 914925e..0000000 --- a/benchmark/benchmark.1d.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/benchmark/benchmark.2d.js b/benchmark/benchmark.2d.js deleted file mode 100644 index ae88336..0000000 --- a/benchmark/benchmark.2d.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 pow = require( '@stdlib/math-base-special-pow' ); -var sqrt = require( '@stdlib/math-base-special-sqrt' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var includes = require( './../lib' ); - - -// VARIABLES // - -var types = [ 'float64' ]; -var orders = [ 'row-major', 'column-major' ]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - ndarray length -* @param {NonNegativeIntegerArray} shape - ndarray shape -* @param {string} xtype - ndarray data type -* @param {string} order - memory layout -* @param {NonNegativeIntegerArray} dims - list of dimensions to reduce -* @returns {Function} benchmark function -*/ -function createBenchmark( len, shape, xtype, order, dims ) { - var x; - - x = discreteUniform( len, 1, 100 ); - x = new ndarray( xtype, x, shape, shape2strides( shape, order ), 0, order ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = includes( x, 101, { - 'dims': dims - }); - if ( typeof out !== 'object' ) { - b.fail( 'should return an ndarray' ); - } - } - b.toc(); - if ( !isndarrayLike( out ) ) { - b.fail( 'should return an ndarray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var dims; - var len; - var min; - var max; - var ord; - var sh; - var t1; - var f; - var i; - var j; - var k; - var n; - var d; - - min = 1; // 10^min - max = 6; // 10^max - - d = [ - [ 0, 1 ], - [ 0 ], - [ 1 ], - [] - ]; - - for ( n = 0; n < d.length; n++ ) { - dims = d[ n ]; - for ( k = 0; k < orders.length; k++ ) { - ord = orders[ k ]; - for ( j = 0; j < types.length; j++ ) { - t1 = types[ j ]; - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - sh = [ len/2, 2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - - sh = [ 2, len/2 ]; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - len = floor( sqrt( len ) ); - sh = [ len, len ]; - len *= len; - f = createBenchmark( len, sh, t1, ord, dims ); - bench( format( '%s:ndims=%d,len=%d,shape=[%s],xorder=%s,xtype=%s,dims=[%s]', pkg, sh.length, len, sh.join(','), ord, t1, dims.join(',') ), f ); - } - } - } - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index e694340..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/includes" -%% click B href "https://github.com/stdlib-js/ndarray-includes/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-includes/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-includes/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-includes/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-includes/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/includes -[production-url]: https://github.com/stdlib-js/ndarray-includes/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-includes/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-includes/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-includes/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-includes/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-includes/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-includes/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 90f394f..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import includes from '../docs/types/index'; -export = includes; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a7f7da2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(a){throw e=0,a}}};var g=q(function(Or,M){M.exports={dims:null,keepdims:!1}});var b=q(function(jr,T){"use strict";var z=require("@stdlib/assert-is-plain-object"),S=require("@stdlib/assert-has-own-property"),I=require("@stdlib/assert-is-boolean").isPrimitive,N=require("@stdlib/assert-is-integer-array").primitives,F=require("@stdlib/assert-is-empty-collection"),L=require("@stdlib/ndarray-base-to-unique-normalized-indices"),c=require("@stdlib/array-base-join"),m=require("@stdlib/string-format");function P(r,e,a){var i;if(!z(a))return new TypeError(m("invalid argument. Options argument must be an object. Value: `%s`.",a));if(S(a,"keepdims")&&(r.keepdims=a.keepdims,!I(r.keepdims)))return new TypeError(m("invalid option. `%s` option must be a boolean. Option: `%s`.","keepdims",r.keepdims));if(S(a,"dims")){if(r.dims=a.dims,!N(r.dims)&&!F(r.dims))return new TypeError(m("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",r.dims));if(i=L(r.dims,e-1),i===null)return new RangeError(m("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",c(r.dims,",")));if(i.length!==r.dims.length)return new Error(m("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",c(r.dims,",")));if(i.length>e)return new RangeError(m("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",e,c(r.dims,",")));r.dims=i}return null}T.exports=P});var C=q(function(Vr,V){"use strict";var G=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),H=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),k=require("@stdlib/assert-is-ndarray-like"),J=require("@stdlib/ndarray-base-unary-reduce-subarray"),K=require("@stdlib/ndarray-base-includes"),Q=require("@stdlib/ndarray-base-spread-dimensions"),U=require("@stdlib/array-base-indices-complement"),W=require("@stdlib/ndarray-shape"),O=require("@stdlib/ndarray-base-order"),X=require("@stdlib/ndarray-base-data-buffer"),Y=require("@stdlib/ndarray-base-strides"),Z=require("@stdlib/ndarray-base-offset"),j=require("@stdlib/ndarray-base-dtype"),_=require("@stdlib/ndarray-empty"),$=require("@stdlib/ndarray-base-ctor"),x=require("@stdlib/ndarray-base-maybe-broadcast-array"),rr=require("@stdlib/ndarray-base-broadcast-scalar"),er=require("@stdlib/strided-base-reinterpret-boolean"),ar=require("@stdlib/array-base-take-indexed"),ir=require("@stdlib/array-base-zero-to"),tr=require("@stdlib/object-assign"),w=require("@stdlib/string-format"),nr=g(),ur=b();function sr(r,e,a){var i,n,o,v,u,t,d,l,p,y,s;if(!k(r))throw new TypeError(w("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(u=W(r),p=u.length,i=tr({},nr),arguments.length>2&&(o=ur(i,p,a),o))throw o;if(i.dims===null&&(i.dims=ir(p)),v=U(p,i.dims),t=ar(u,v),l=j(r),d=O(r),k(e)){if(!H(j(e),l))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{y=x(e,t)}catch(Tr){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(G(e,l))y=rr(e,l,t,d);else throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return s=_(t,{dtype:"bool",order:d}),n=new $("uint8",er(X(s),0),t,Y(s,!1),Z(s),O(s)),J(K,[r,n,y],i.dims),i.keepdims&&(s=Q(p,s,v,!0)),s}V.exports=sr});var D=q(function(Cr,B){"use strict";var or=require("@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible"),dr=require("@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast"),h=require("@stdlib/assert-is-ndarray-like"),vr=require("@stdlib/ndarray-base-unary-reduce-subarray"),mr=require("@stdlib/ndarray-ndims"),lr=require("@stdlib/ndarray-base-includes"),A=require("@stdlib/ndarray-shape"),pr=require("@stdlib/ndarray-base-order"),R=require("@stdlib/ndarray-base-dtype"),qr=require("@stdlib/ndarray-base-maybe-broadcast-array"),fr=require("@stdlib/ndarray-base-broadcast-scalar"),yr=require("@stdlib/object-assign"),gr=require("@stdlib/array-base-zero-to"),f=require("@stdlib/string-format"),cr=g(),br=b();function wr(r,e,a,i){var n,o,v,u,t,d;if(!h(r))throw new TypeError(f("invalid argument. First argument must be an ndarray-like object. Value: `%s`.",r));if(!h(a))throw new TypeError(f("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(t=mr(r),n=yr({},cr),arguments.length>3&&(o=br(n,t,i),o))throw o;if(n.dims===null&&(n.dims=gr(t)),u=R(r),v=pr(r),h(e)){if(!dr(R(e),u))throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));try{d=qr(e,A(a))}catch(l){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else if(or(e,u))d=fr(e,u,A(a),v);else throw new TypeError(f("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",e));return vr(lr,[r,a,d],n.dims),a}B.exports=wr});var hr=require("@stdlib/utils-define-nonenumerable-read-only-property"),E=C(),Sr=D();hr(E,"assign",Sr);module.exports=E; -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 c222237..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/main.js", "../lib/assign.js", "../lib/index.js"], - "sourcesContent": ["{\n \"dims\": null,\n \"keepdims\": false\n}\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// 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives;\nvar isEmptyCollection = require( '@stdlib/assert-is-empty-collection' );\nvar normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );\nvar join = require( '@stdlib/array-base-join' );\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\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, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );\nvar indicesComplement = require( '@stdlib/array-base-indices-complement' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getData = require( '@stdlib/ndarray-base-data-buffer' );\nvar getStrides = require( '@stdlib/ndarray-base-strides' );\nvar getOffset = require( '@stdlib/ndarray-base-offset' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar empty = require( '@stdlib/ndarray-empty' );\nvar ndarrayCtor = require( '@stdlib/ndarray-base-ctor' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar takeIndexed = require( '@stdlib/array-base-take-indexed' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = includes;\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// MODULES //\n\nvar isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length\nvar isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' );\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' );\nvar ndims = require( '@stdlib/ndarray-ndims' );\nvar base = require( '@stdlib/ndarray-base-includes' );\nvar getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland\nvar getOrder = require( '@stdlib/ndarray-base-order' );\nvar getDType = require( '@stdlib/ndarray-base-dtype' );\nvar maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );\nvar broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );\nvar objectAssign = require( '@stdlib/object-assign' );\nvar zeroTo = require( '@stdlib/array-base-zero-to' );\nvar format = require( '@stdlib/string-format' );\nvar defaults = require( './defaults.json' );\nvar validate = require( './validate.js' );\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var empty = require( '@stdlib/ndarray-empty' );\n* var includes = require( '@stdlib/ndarray-includes' );\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"assign\": \"main.assign\" }\n"], - "mappings": "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", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isIntegerArray", "isEmptyCollection", "normalizeIndices", "join", "format", "validate", "opts", "ndims", "options", "tmp", "require_main", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "base", "spreadDimensions", "indicesComplement", "getShape", "getOrder", "getData", "getStrides", "getOffset", "getDType", "empty", "ndarrayCtor", "maybeBroadcastArray", "broadcastScalar", "reinterpretBoolean", "takeIndexed", "zeroTo", "objectAssign", "format", "defaults", "validate", "includes", "x", "searchElement", "options", "opts", "view", "err", "idx", "shx", "shy", "ord", "dt", "N", "v", "y", "require_assign", "__commonJSMin", "exports", "module", "isScalarMostlySafeCompatible", "isMostlySafeCast", "isndarrayLike", "unaryReduceSubarray", "ndims", "base", "getShape", "getOrder", "getDType", "maybeBroadcastArray", "broadcastScalar", "objectAssign", "zeroTo", "format", "defaults", "validate", "assign", "x", "searchElement", "y", "options", "opts", "err", "ord", "dt", "N", "v", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 04d9390..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,93 +0,0 @@ - -{{alias}}( x, searchElement[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - options.keepdims: boolean (optional) - Boolean indicating whether the reduced dimensions should be included in - the returned ndarray as singleton dimensions. Default: false. - - Returns - ------- - out: ndarray - Output ndarray. When performing a reduction over all elements, the - function returns a zero-dimensional ndarray containing the result. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias}}( x, 3.0 ) - - > y.get() - true - > y = {{alias}}( x, 3.0, { 'keepdims': true } ) - - > {{alias:@stdlib/ndarray/to-array}}( y ) - [ [ true ] ] - > y.get( 0, 0 ) - true - - -{{alias}}.assign( x, searchElement, y[, options] ) - Tests whether an ndarray contains a specified value along one or more - dimensions and assigns the results to a provided output ndarray. - - Parameters - ---------- - x: ndarray - Input ndarray. - - searchElement: ndarray|any - Search element. Must be broadcast-compatible with the non-reduced - dimensions of the input ndarray. Must have a data type which can be - safely cast to the data type of the input ndarray. - - y: ndarray - Output ndarray. The output shape must match the shape of the non-reduced - dimensions of the input ndarray. - - options: Object (optional) - Function options. - - options.dims: Array (optional) - List of dimensions over which to perform a reduction. If not provided, - the function performs a reduction over all elements in a provided input - ndarray. - - Returns - ------- - y: ndarray - Output ndarray. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ); - > var y = {{alias:@stdlib/ndarray/from-scalar}}( false ); - > var out = {{alias}}.assign( x, 3.0, y ) - - > var bool = ( out === y ) - true - > y.get() - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1911572..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,199 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( '@stdlib/ndarray-zeros' ); -import empty = require( '@stdlib/ndarray-empty' ); -import includes = require( './index' ); - - -// TESTS // - -// The function returns an boolean ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0 ); // $ExpectType boolndarray - includes( x, 0.0, {} ); // $ExpectType boolndarray - includes( x, 0.0, { 'keepdims': true } ); // $ExpectType boolndarray - includes( x, 0.0, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - includes( 5, 0.0 ); // $ExpectError - includes( true, 0.0 ); // $ExpectError - includes( false, 0.0 ); // $ExpectError - includes( null, 0.0 ); // $ExpectError - includes( undefined, 0.0 ); // $ExpectError - includes( {}, 0.0 ); // $ExpectError - includes( [ 1 ], 0.0 ); // $ExpectError - includes( ( x: number ): number => x, 0.0 ); // $ExpectError - - includes( 5, 0.0, {} ); // $ExpectError - includes( true, 0.0, {} ); // $ExpectError - includes( false, 0.0, {} ); // $ExpectError - includes( null, 0.0, {} ); // $ExpectError - includes( undefined, 0.0, {} ); // $ExpectError - includes( {}, 0.0, {} ); // $ExpectError - includes( [ 1 ], 0.0, {} ); // $ExpectError - includes( ( x: number ): number => x, 0.0, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, '5' ); // $ExpectError - includes( x, 0.0, 5 ); // $ExpectError - includes( x, 0.0, true ); // $ExpectError - includes( x, 0.0, false ); // $ExpectError - includes( x, 0.0, null ); // $ExpectError - includes( x, 0.0, [ 1 ] ); // $ExpectError - includes( x, 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `keepdims` option which is not a boolean... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'keepdims': '5' } ); // $ExpectError - includes( x, 0.0, { 'keepdims': 5 } ); // $ExpectError - includes( x, 0.0, { 'keepdims': null } ); // $ExpectError - includes( x, 0.0, { 'keepdims': [ 1 ] } ); // $ExpectError - includes( x, 0.0, { 'keepdims': {} } ); // $ExpectError - includes( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - - includes( x, 0.0, { 'dims': '5' } ); // $ExpectError - includes( x, 0.0, { 'dims': 5 } ); // $ExpectError - includes( x, 0.0, { 'dims': null } ); // $ExpectError - includes( x, 0.0, { 'dims': true } ); // $ExpectError - includes( x, 0.0, { 'dims': false } ); // $ExpectError - includes( x, 0.0, { 'dims': {} } ); // $ExpectError - includes( x, 0.0, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - - includes(); // $ExpectError - includes( x ); // $ExpectError - includes( x, 0.0, {}, {} ); // $ExpectError -} - -// Attached to the function is an `assign` method which returns an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, {} ); // $ExpectType boolndarray - includes.assign( x, 0.0, y, { 'dims': [ 0 ] } ); // $ExpectType boolndarray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray... -{ - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( 5, 0.0, y ); // $ExpectError - includes.assign( true, 0.0, y ); // $ExpectError - includes.assign( false, 0.0, y ); // $ExpectError - includes.assign( null, 0.0, y ); // $ExpectError - includes.assign( undefined, 0.0, y ); // $ExpectError - includes.assign( {}, 0.0, y ); // $ExpectError - includes.assign( [ 1 ], 0.0, y ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y ); // $ExpectError - - includes.assign( 5, 0.0, y, {} ); // $ExpectError - includes.assign( true, 0.0, y, {} ); // $ExpectError - includes.assign( false, 0.0, y, {} ); // $ExpectError - includes.assign( null, 0.0, y, {} ); // $ExpectError - includes.assign( undefined, 0.0, y, {} ); // $ExpectError - includes.assign( {}, 0.0, y, {} ); // $ExpectError - includes.assign( [ 1 ], 0.0, y, {} ); // $ExpectError - includes.assign( ( x: number ): number => x, 0.0, y, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an ndarray... -{ - const x = zeros( [ 2, 2 ] ); - - includes.assign( x, 0.0, 5 ); // $ExpectError - includes.assign( x, 0.0, true ); // $ExpectError - includes.assign( x, 0.0, false ); // $ExpectError - includes.assign( x, 0.0, null ); // $ExpectError - includes.assign( x, 0.0, undefined ); // $ExpectError - includes.assign( x, 0.0, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x ); // $ExpectError - - includes.assign( x, 0.0, 5, {} ); // $ExpectError - includes.assign( x, 0.0, true, {} ); // $ExpectError - includes.assign( x, 0.0, false, {} ); // $ExpectError - includes.assign( x, 0.0, null, {} ); // $ExpectError - includes.assign( x, 0.0, undefined, {} ); // $ExpectError - includes.assign( x, 0.0, {}, {} ); // $ExpectError - includes.assign( x, 0.0, [ 1 ], {} ); // $ExpectError - includes.assign( x, 0.0, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an object... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, '5' ); // $ExpectError - includes.assign( x, 0.0, y, 5 ); // $ExpectError - includes.assign( x, 0.0, y, true ); // $ExpectError - includes.assign( x, 0.0, y, false ); // $ExpectError - includes.assign( x, 0.0, y, null ); // $ExpectError - includes.assign( x, 0.0, y, [ 1 ] ); // $ExpectError - includes.assign( x, 0.0, y, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dims` option which is not an array of numbers... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign( x, 0.0, y, { 'dims': '5' } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': 5 } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': null } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': true } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': false } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': {} } ); // $ExpectError - includes.assign( x, 0.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = zeros( [ 2, 2 ] ); - const y = empty( [], { 'dtype': 'bool' } ); - - includes.assign(); // $ExpectError - includes.assign( x ); // $ExpectError - includes.assign( x, 0.0 ); // $ExpectError - includes.assign( x, 0.0, y, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 525b7e6..0000000 --- a/examples/index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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-base-discrete-uniform' ).factory; -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var fillBy = require( '@stdlib/ndarray-fill-by' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var includes = require( './../lib' ); - -var x = zeros( [ 2, 4, 5 ], { - 'dtype': 'float64' -}); -x = fillBy( x, discreteUniform( 0, 10 ) ); -console.log( ndarray2array( x ) ); - -var y = includes( x, 1 ); -console.log( 'includes(x[:,:,:], 1) =' ); -console.log( y.get() ); - -y = includes( x, 2, { - 'dims': [ 0 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,k], 2) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 3, { - 'dims': [ 1 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,k], 3) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 4, { - 'dims': [ 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,j,:], 4) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 5, { - 'dims': [ 0, 1 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,k], 5) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 6, { - 'dims': [ 0, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,j,:], 6) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 7, { - 'dims': [ 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[i,:,:], 7) =' ); -console.log( ndarray2array( y ) ); - -y = includes( x, 8, { - 'dims': [ 0, 1, 2 ], - 'keepdims': true -}); -console.log( 'includes(x[:,:,:], 8) =' ); -console.log( ndarray2array( y ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f4ddce6..ad24b59 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, boolndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..727292b --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-scalar-mostly-safe-compatible@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-mostly-safe-data-type-cast@v0.3.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-unary-reduce-subarray@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-includes@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-spread-dimensions@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-indices-complement@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-order@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-data-buffer@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides@v0.2.3-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-offset@v0.2.3-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-empty@v0.3.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.3.1-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-maybe-broadcast-array@v0.2.5-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-broadcast-scalar@v0.2.4-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-take-indexed@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@v0.2.2-esm/index.mjs";import x from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.3-esm/index.mjs";import k from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.3-esm/index.mjs";import{isPrimitive as T}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{primitives as S}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer-array@v0.2.3-esm/index.mjs";import V from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-empty-collection@v0.2.4-esm/index.mjs";import O from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-unique-normalized-indices@v0.1.1-esm/index.mjs";import z from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-join@v0.1.2-esm/index.mjs";import R from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndims@v0.2.3-esm/index.mjs";var q={dims:null,keepdims:!1};function N(e,s,t){var r;if(!E(t))return new TypeError(w("null2V",t));if(k(t,"keepdims")&&(e.keepdims=t.keepdims,!T(e.keepdims)))return new TypeError(w("null2o","keepdims",e.keepdims));if(k(t,"dims")){if(e.dims=t.dims,!S(e.dims)&&!V(e.dims))return new TypeError(w("invalid option. `%s` option must be an array of integers. Option: `%s`.","dims",e.dims));if(null===(r=O(e.dims,s-1)))return new RangeError(w("invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].","dims",z(e.dims,",")));if(r.length!==e.dims.length)return new Error(w("invalid option. `%s` option contains duplicate indices. Option: [%s].","dims",z(e.dims,",")));if(r.length>s)return new RangeError(w("invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].","dims",s,z(e.dims,",")));e.dims=r}return null}function A(e,E,k){var T,S,V,O,z,R,A,B,C,D,F;if(!r(e))throw new TypeError(w("null5t",e));if(C=(z=m(e)).length,T=x({},q),arguments.length>2&&(V=N(T,C,k)))throw V;if(null===T.dims&&(T.dims=g(C)),O=a(C,T.dims),R=y(z,O),B=h(e),A=o(e),r(E)){if(!t(h(E),B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));try{D=v(E,R)}catch(V){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(E,B))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",E));D=f(E,B,R,A)}return F=c(R,{dtype:"bool",order:A}),S=new b("uint8",u(l(F),0),R,p(F,!1),j(F),o(F)),i(n,[e,S,D],T.dims),T.keepdims&&(F=d(C,F,O,!0)),F}function B(e,d,a,l){var p,j,c,b,u,y;if(!r(e))throw new TypeError(w("null5t",e));if(!r(a))throw new TypeError(w("invalid argument. Third argument must be an ndarray-like object. Value: `%s`.",a));if(u=R(e),p=x({},q),arguments.length>3&&(j=N(p,u,l)))throw j;if(null===p.dims&&(p.dims=g(u)),b=h(e),c=o(e),r(d)){if(!t(h(d),b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));try{y=v(d,m(a))}catch(j){throw new Error("invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.")}}else{if(!s(d,b))throw new TypeError(w("invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.",d));y=f(d,b,m(a),c)}return i(n,[e,a,y],p.dims),a}e(A,"assign",B);export{B as assign,A as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..29ee4ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/validate.js","../lib/main.js","../lib/assign.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 { primitives as isIntegerArray } from '@stdlib/assert-is-integer-array';\nimport isEmptyCollection from '@stdlib/assert-is-empty-collection';\nimport normalizeIndices from '@stdlib/ndarray-base-to-unique-normalized-indices';\nimport join from '@stdlib/array-base-join';\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 {NonNegativeInteger} ndims - number of input ndarray dimensions\n* @param {Options} options - function options\n* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'keepdims': true\n* };\n* var err = validate( opts, 3, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, ndims, options ) {\n\tvar tmp;\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'null2V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'keepdims' ) ) {\n\t\topts.keepdims = options.keepdims;\n\t\tif ( !isBoolean( opts.keepdims ) ) {\n\t\t\treturn new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dims' ) ) {\n\t\topts.dims = options.dims;\n\t\tif ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) );\n\t\t}\n\t\ttmp = normalizeIndices( opts.dims, ndims-1 );\n\t\tif ( tmp === null ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length !== opts.dims.length ) {\n\t\t\treturn new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );\n\t\t}\n\t\tif ( tmp.length > ndims ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );\n\t\t}\n\t\topts.dims = tmp;\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'use strict';\n\n// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport base from '@stdlib/ndarray-base-includes';\nimport spreadDimensions from '@stdlib/ndarray-base-spread-dimensions';\nimport indicesComplement from '@stdlib/array-base-indices-complement';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input array originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getData from '@stdlib/ndarray-base-data-buffer';\nimport getStrides from '@stdlib/ndarray-base-strides';\nimport getOffset from '@stdlib/ndarray-base-offset';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport empty from '@stdlib/ndarray-empty';\nimport ndarrayCtor from '@stdlib/ndarray-base-ctor';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport reinterpretBoolean from '@stdlib/strided-base-reinterpret-boolean';\nimport takeIndexed from '@stdlib/array-base-take-indexed';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport objectAssign from '@stdlib/object-assign';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} options argument must be an object\n* @throws {RangeError} dimension indices must not exceed input ndarray bounds\n* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction includes( x, searchElement, options ) {\n\tvar opts;\n\tvar view;\n\tvar err;\n\tvar idx;\n\tvar shx;\n\tvar shy;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\tvar y;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tshx = getShape( x );\n\tN = shx.length;\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// When a list of dimensions is not provided, reduce the entire input array across all dimensions...\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve the list of non-reduced dimensions:\n\tidx = indicesComplement( N, opts.dims );\n\n\t// Resolve the output array shape:\n\tshy = takeIndexed( shx, idx );\n\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, shy );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, shy, ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array:\n\ty = empty( shy, {\n\t\t'dtype': 'bool',\n\t\t'order': ord\n\t});\n\n\t// Reinterpret the output array as an \"indexed\" array to ensure faster element access:\n\tview = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) );\n\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, view, v ], opts.dims );\n\n\t// Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array...\n\tif ( opts.keepdims ) {\n\t\ty = spreadDimensions( N, y, idx, true );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default includes;\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// MODULES //\n\nimport isScalarMostlySafeCompatible from '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible'; // eslint-disable-line id-length\nimport isMostlySafeCast from '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast';\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport unaryReduceSubarray from '@stdlib/ndarray-base-unary-reduce-subarray';\nimport ndims from '@stdlib/ndarray-ndims';\nimport base from '@stdlib/ndarray-base-includes';\nimport getShape from '@stdlib/ndarray-shape'; // note: non-base accessor is intentional due to the input arrays originating in userland\nimport getOrder from '@stdlib/ndarray-base-order';\nimport getDType from '@stdlib/ndarray-base-dtype';\nimport maybeBroadcastArray from '@stdlib/ndarray-base-maybe-broadcast-array';\nimport broadcastScalar from '@stdlib/ndarray-base-broadcast-scalar';\nimport objectAssign from '@stdlib/object-assign';\nimport zeroTo from '@stdlib/array-base-zero-to';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport defaults from './defaults.json';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray.\n*\n* @param {ndarray} x - input ndarray\n* @param {(ndarray|*)} searchElement - search element\n* @param {ndarray} y - output ndarray\n* @param {Options} [options] - function options\n* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction\n* @throws {TypeError} first argument must be an ndarray-like object\n* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray\n* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray\n* @throws {TypeError} third argument must be an ndarray-like object\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {ndarray} output ndarray\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\nfunction assign( x, searchElement, y, options ) {\n\tvar opts;\n\tvar err;\n\tvar ord;\n\tvar dt;\n\tvar N;\n\tvar v;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'null5t', x ) );\n\t}\n\tif ( !isndarrayLike( y ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) );\n\t}\n\tN = ndims( x );\n\n\topts = objectAssign( {}, defaults );\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, N, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dims === null ) {\n\t\topts.dims = zeroTo( N );\n\t}\n\t// Resolve input array meta data:\n\tdt = getDType( x );\n\tord = getOrder( x );\n\n\t// Determine how to broadcast the search element...\n\tif ( isndarrayLike( searchElement ) ) {\n\t\tif ( !isMostlySafeCast( getDType( searchElement ), dt ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t\t}\n\t\ttry {\n\t\t\tv = maybeBroadcastArray( searchElement, getShape( y ) );\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\tthrow new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' );\n\t\t}\n\t} else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) {\n\t\tv = broadcastScalar( searchElement, dt, getShape( y ), ord );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) );\n\t}\n\t// Perform the reduction:\n\tunaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc)\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\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* Test whether an ndarray contains a specified value along one or more dimensions.\n*\n* @module @stdlib/ndarray-includes\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var sh = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );\n*\n* // Perform reduction:\n* var out = includes( x, 6.0 );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n* import ndarray from '@stdlib/ndarray-ctor';\n* import empty from '@stdlib/ndarray-empty';\n* import includes from '@stdlib/ndarray-includes';\n*\n* // Create a data buffer:\n* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );\n*\n* // Define the shape of the input array:\n* var shape = [ 3, 1, 2 ];\n*\n* // Define the array strides:\n* var sx = [ 4, 4, 1 ];\n*\n* // Define the index offset:\n* var ox = 1;\n*\n* // Create an input ndarray:\n* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );\n*\n* // Create an output ndarray:\n* var y = empty( [], {\n* 'dtype': 'bool'\n* });\n*\n* // Perform reduction:\n* var out = includes.assign( x, 6.0, y );\n* // returns \n*\n* var v = out.get();\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"assign\": \"main.assign\" }\n"],"names":["validate","opts","ndims","options","tmp","isObject","TypeError","format","hasOwnProp","keepdims","isBoolean","dims","isIntegerArray","isEmptyCollection","normalizeIndices","RangeError","join","length","Error","includes","x","searchElement","view","err","idx","shx","shy","ord","dt","N","v","y","isndarrayLike","getShape","objectAssign","defaults","arguments","zeroTo","indicesComplement","takeIndexed","getDType","getOrder","isMostlySafeCast","maybeBroadcastArray","isScalarMostlySafeCompatible","broadcastScalar","empty","dtype","order","ndarrayCtor","reinterpretBoolean","getData","getStrides","getOffset","unaryReduceSubarray","base","spreadDimensions","assign","setReadOnly","main"],"mappings":";;ulGAuDA,SAASA,EAAUC,EAAMC,EAAOC,GAC/B,IAAIC,EACJ,IAAMC,EAAUF,GACf,OAAO,IAAIG,UAAWC,EAAQ,SAAUJ,IAEzC,GAAKK,EAAYL,EAAS,cACzBF,EAAKQ,SAAWN,EAAQM,UAClBC,EAAWT,EAAKQ,WACrB,OAAO,IAAIH,UAAWC,EAAQ,SAAU,WAAYN,EAAKQ,WAG3D,GAAKD,EAAYL,EAAS,QAAW,CAEpC,GADAF,EAAKU,KAAOR,EAAQQ,MACdC,EAAgBX,EAAKU,QAAWE,EAAmBZ,EAAKU,MAC7D,OAAO,IAAIL,UAAWC,EAAQ,0EAA2E,OAAQN,EAAKU,OAGvH,GAAa,QADbP,EAAMU,EAAkBb,EAAKU,KAAMT,EAAM,IAExC,OAAO,IAAIa,WAAYR,EAAQ,uFAAwF,OAAQS,EAAMf,EAAKU,KAAM,OAEjJ,GAAKP,EAAIa,SAAWhB,EAAKU,KAAKM,OAC7B,OAAO,IAAIC,MAAOX,EAAQ,wEAAyE,OAAQS,EAAMf,EAAKU,KAAM,OAE7H,GAAKP,EAAIa,OAASf,EACjB,OAAO,IAAIa,WAAYR,EAAQ,gIAAiI,OAAQL,EAAOc,EAAMf,EAAKU,KAAM,OAEjMV,EAAKU,KAAOP,CACZ,CACD,OAAO,IACR,CCSA,SAASe,EAAUC,EAAGC,EAAelB,GACpC,IAAIF,EACAqB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAMxC,GAHAS,GADAJ,EAAMQ,EAAUb,IACRH,OAERhB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAkBR,GAdmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBL,EAAMc,EAAmBT,EAAG5B,EAAKU,MAGjCe,EAAMa,EAAad,EAAKD,GAGxBI,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeK,EACxC,CAAC,MAAQH,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIF,EAAKC,EAG7C,CAiBD,OAfAI,EAAIe,EAAOpB,EAAK,CACfqB,MAAS,OACTC,MAASrB,IAIVL,EAAO,IAAI2B,EAAa,QAASC,EAAoBC,EAASpB,GAAK,GAAKL,EAAK0B,EAAYrB,GAAG,GAASsB,EAAWtB,GAAKU,EAAUV,IAG/HuB,EAAqBC,EAAM,CAAEnC,EAAGE,EAAMQ,GAAK7B,EAAKU,MAG3CV,EAAKQ,WACTsB,EAAIyB,EAAkB3B,EAAGE,EAAGP,GAAK,IAE3BO,CACR,CC3EA,SAAS0B,EAAQrC,EAAGC,EAAeU,EAAG5B,GACrC,IAAIF,EACAsB,EACAI,EACAC,EACAC,EACAC,EAEJ,IAAME,EAAeZ,GACpB,MAAM,IAAId,UAAWC,EAAQ,SAAUa,IAExC,IAAMY,EAAeD,GACpB,MAAM,IAAIzB,UAAWC,EAAQ,gFAAiFwB,IAK/G,GAHAF,EAAI3B,EAAOkB,GAEXnB,EAAOiC,EAAc,GAAIC,GACpBC,UAAUnB,OAAS,IACvBM,EAAMvB,EAAUC,EAAM4B,EAAG1B,IAExB,MAAMoB,EAWR,GARmB,OAAdtB,EAAKU,OACTV,EAAKU,KAAO0B,EAAQR,IAGrBD,EAAKY,EAAUpB,GACfO,EAAMc,EAAUrB,GAGXY,EAAeX,GAAkB,CACrC,IAAMqB,EAAkBF,EAAUnB,GAAiBO,GAClD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAEpI,IACCS,EAAIa,EAAqBtB,EAAeY,EAAUF,GAClD,CAAC,MAAQR,GACT,MAAM,IAAIL,MAAO,qHACjB,CACD,KAAM,KAAK0B,EAA8BvB,EAAeO,GAGxD,MAAM,IAAItB,UAAWC,EAAQ,qGAAsGc,IAFnIS,EAAIe,EAAiBxB,EAAeO,EAAIK,EAAUF,GAAKJ,EAGvD,CAGD,OADA2B,EAAqBC,EAAM,CAAEnC,EAAGW,EAAGD,GAAK7B,EAAKU,MACtCoB,CACR,CC3CA2B,EAAAC,EAAA,SAAAF"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index d3aafba..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var ndims = require( '@stdlib/ndarray-ndims' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input arrays originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var objectAssign = require( '@stdlib/object-assign' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions and assigns the results to a provided output ndarray. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {ndarray} y - output ndarray -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} third argument must be an ndarray-like object -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function assign( x, searchElement, y, options ) { - var opts; - var err; - var ord; - var dt; - var N; - var v; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - if ( !isndarrayLike( y ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', y ) ); - } - N = ndims( x ); - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 3 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, getShape( y ) ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, getShape( y ), ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Perform the reduction: - unaryReduceSubarray( base, [ x, y, v ], opts.dims ); // note: we assume that this lower-level function handles further validation of the output ndarray (e.g., expected shape, etc) - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index 08433b3..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dims": null, - "keepdims": false -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e0e191b..0000000 --- a/lib/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether an ndarray contains a specified value along one or more dimensions. -* -* @module @stdlib/ndarray-includes -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var empty = require( '@stdlib/ndarray-empty' ); -* var includes = require( '@stdlib/ndarray-includes' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var shape = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); -* -* // Create an output ndarray: -* var y = empty( [], { -* 'dtype': 'bool' -* }); -* -* // Perform reduction: -* var out = includes.assign( x, 6.0, y ); -* // returns -* -* var v = out.get(); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4a2b4b0..0000000 --- a/lib/main.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isScalarMostlySafeCompatible = require( '@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible' ); // eslint-disable-line id-length -var isMostlySafeCast = require( '@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var unaryReduceSubarray = require( '@stdlib/ndarray-base-unary-reduce-subarray' ); -var base = require( '@stdlib/ndarray-base-includes' ); -var spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' ); -var indicesComplement = require( '@stdlib/array-base-indices-complement' ); -var getShape = require( '@stdlib/ndarray-shape' ); // note: non-base accessor is intentional due to the input array originating in userland -var getOrder = require( '@stdlib/ndarray-base-order' ); -var getData = require( '@stdlib/ndarray-base-data-buffer' ); -var getStrides = require( '@stdlib/ndarray-base-strides' ); -var getOffset = require( '@stdlib/ndarray-base-offset' ); -var getDType = require( '@stdlib/ndarray-base-dtype' ); -var empty = require( '@stdlib/ndarray-empty' ); -var ndarrayCtor = require( '@stdlib/ndarray-base-ctor' ); -var maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' ); -var broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var takeIndexed = require( '@stdlib/array-base-take-indexed' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var objectAssign = require( '@stdlib/object-assign' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var defaults = require( './defaults.json' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Tests whether an ndarray contains a specified value along one or more dimensions. -* -* @param {ndarray} x - input ndarray -* @param {(ndarray|*)} searchElement - search element -* @param {Options} [options] - function options -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @param {boolean} [options.keepdims=false] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @throws {TypeError} first argument must be an ndarray-like object -* @throws {Error} second argument must be broadcast-compatible with the non-reduced dimensions of the input ndarray -* @throws {TypeError} second argument must have a data type which can be safely cast to the data type of the input ndarray -* @throws {TypeError} options argument must be an object -* @throws {RangeError} dimension indices must not exceed input ndarray bounds -* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions -* @throws {Error} must provide valid options -* @returns {ndarray} output ndarray -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* // Create a data buffer: -* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); -* -* // Define the shape of the input array: -* var sh = [ 3, 1, 2 ]; -* -* // Define the array strides: -* var sx = [ 4, 4, 1 ]; -* -* // Define the index offset: -* var ox = 1; -* -* // Create an input ndarray: -* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' ); -* -* // Perform reduction: -* var out = includes( x, 6.0 ); -* // returns -* -* var v = out.get(); -* // returns true -*/ -function includes( x, searchElement, options ) { - var opts; - var view; - var err; - var idx; - var shx; - var shy; - var ord; - var dt; - var N; - var v; - var y; - - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'null5t', x ) ); - } - shx = getShape( x ); - N = shx.length; - - opts = objectAssign( {}, defaults ); - if ( arguments.length > 2 ) { - err = validate( opts, N, options ); - if ( err ) { - throw err; - } - } - // When a list of dimensions is not provided, reduce the entire input array across all dimensions... - if ( opts.dims === null ) { - opts.dims = zeroTo( N ); - } - // Resolve the list of non-reduced dimensions: - idx = indicesComplement( N, opts.dims ); - - // Resolve the output array shape: - shy = takeIndexed( shx, idx ); - - // Resolve input array meta data: - dt = getDType( x ); - ord = getOrder( x ); - - // Determine how to broadcast the search element... - if ( isndarrayLike( searchElement ) ) { - if ( !isMostlySafeCast( getDType( searchElement ), dt ) ) { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - try { - v = maybeBroadcastArray( searchElement, shy ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new Error( 'invalid argument. Second argument must be broadcast-compatible with the non-reduced dimensions of the input array.' ); - } - } else if ( isScalarMostlySafeCompatible( searchElement, dt ) ) { - v = broadcastScalar( searchElement, dt, shy, ord ); - } else { - throw new TypeError( format( 'invalid argument. Second argument cannot be safely cast to the input array data type. Value: `%s`.', searchElement ) ); - } - // Initialize an output array whose shape matches that of the non-reduced dimensions and which has the same memory layout as the input array: - y = empty( shy, { - 'dtype': 'bool', - 'order': ord - }); - - // Reinterpret the output array as an "indexed" array to ensure faster element access: - view = new ndarrayCtor( 'uint8', reinterpretBoolean( getData( y ), 0 ), shy, getStrides( y, false ), getOffset( y ), getOrder( y ) ); - - // Perform the reduction: - unaryReduceSubarray( base, [ x, view, v ], opts.dims ); - - // Check whether we need to reinsert singleton dimensions which can be useful for broadcasting the returned output array to the shape of the original input array... - if ( opts.keepdims ) { - y = spreadDimensions( N, y, idx, true ); - } - return y; -} - - -// EXPORTS // - -module.exports = includes; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 975bdc9..0000000 --- a/lib/validate.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isIntegerArray = require( '@stdlib/assert-is-integer-array' ).primitives; -var isEmptyCollection = require( '@stdlib/assert-is-empty-collection' ); -var normalizeIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' ); -var join = require( '@stdlib/array-base-join' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {NonNegativeInteger} ndims - number of input ndarray dimensions -* @param {Options} options - function options -* @param {boolean} [options.keepdims] - boolean indicating whether the reduced dimensions should be included in the returned ndarray as singleton dimensions -* @param {IntegerArray} [options.dims] - list of dimensions over which to perform a reduction -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'keepdims': true -* }; -* var err = validate( opts, 3, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, ndims, options ) { - var tmp; - if ( !isObject( options ) ) { - return new TypeError( format( 'null2V', options ) ); - } - if ( hasOwnProp( options, 'keepdims' ) ) { - opts.keepdims = options.keepdims; - if ( !isBoolean( opts.keepdims ) ) { - return new TypeError( format( 'null2o', 'keepdims', opts.keepdims ) ); - } - } - if ( hasOwnProp( options, 'dims' ) ) { - opts.dims = options.dims; - if ( !isIntegerArray( opts.dims ) && !isEmptyCollection( opts.dims ) ) { - return new TypeError( format( 'invalid option. `%s` option must be an array of integers. Option: `%s`.', 'dims', opts.dims ) ); - } - tmp = normalizeIndices( opts.dims, ndims-1 ); - if ( tmp === null ) { - return new RangeError( format( 'invalid option. `%s` option contains an out-of-bounds dimension index. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length !== opts.dims.length ) { - return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) ); - } - if ( tmp.length > ndims ) { - return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) ); - } - opts.dims = tmp; - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aa7ae81..5b86d67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Test whether an ndarray contains a specified value along one or more dimensions.", "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,73 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-indices-complement": "^0.1.1", - "@stdlib/array-base-join": "^0.1.2", - "@stdlib/array-base-take-indexed": "^0.2.3", - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-empty-collection": "^0.2.4", - "@stdlib/assert-is-integer-array": "^0.2.3", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/ndarray-base-assert-is-mostly-safe-data-type-cast": "^0.3.1", - "@stdlib/ndarray-base-assert-is-scalar-mostly-safe-compatible": "^0.1.1", - "@stdlib/ndarray-base-broadcast-scalar": "^0.2.4", - "@stdlib/ndarray-base-ctor": "^0.3.1", - "@stdlib/ndarray-base-data-buffer": "^0.2.3", - "@stdlib/ndarray-base-dtype": "^0.2.3", - "@stdlib/ndarray-base-includes": "^0.1.1", - "@stdlib/ndarray-base-maybe-broadcast-array": "^0.2.5", - "@stdlib/ndarray-base-offset": "^0.2.3", - "@stdlib/ndarray-base-order": "^0.2.3", - "@stdlib/ndarray-base-spread-dimensions": "^0.1.1", - "@stdlib/ndarray-base-strides": "^0.2.3", - "@stdlib/ndarray-base-to-unique-normalized-indices": "^0.1.1", - "@stdlib/ndarray-base-unary-reduce-subarray": "^0.1.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-ndims": "^0.2.3", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/object-assign": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/error-tools-fmtprodmsg": "^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/assert-is-method": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/math-base-special-sqrt": "^0.2.3", - "@stdlib/ndarray-base-shape2strides": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-fill-by": "^0.1.1", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.1", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "strided", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ebc8aa2 --- /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 c883090..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 includes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof includes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( isMethod( includes, 'assign' ), true, 'returns expected value' ); - t.end(); -});