From 16502b72dd83ec64ba5525b2329807c32eb03b01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 18 May 2024 01:51:13 +0000 Subject: [PATCH 01/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f222cb8..548d75b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.1", "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.1", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 71a26ca1387c4a3ef33f215761b2fae77d41a683 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 18 May 2024 01:53:25 +0000 Subject: [PATCH 02/22] Auto-generated commit --- .editorconfig | 181 - .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 | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 259 -- examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 325 -- test/test.js | 41 - test/test.main.js | 158 - 47 files changed, 4873 insertions(+), 4871 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 .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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 2733e7b..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/array/base/mskfilter-map) 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/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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 f92a6c5..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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index 7cfdbfb..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 29e5a06..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index d0b366d..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, fcn[, thisArg] ) - Applies a mask and mapping function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 38f6761..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,259 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 bbf5f50..689dd79 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array2D, Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..38b42db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3788844 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 1d5f28d..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,325 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = reinterpret(new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ) ); - - mask = [ 1, 0 ]; - out = reinterpret( zeros( 1, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 1.0, 4.0, 25.0, 36.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 0, 0 ]; - out = reinterpret( zeros( 0, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 0, 1 ]; - out = reinterpret( zeros( 1, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 9.0, 16.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 1, 1 ]; - out = reinterpret( zeros( 3, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 1.0, 4.0, 9.0, 16.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 1, 0 ]; - out = reinterpret( zeros( 3, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = reinterpret( new Complex64Array( [ 0.0, 0.0, 1.0, 4.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all element equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = reinterpret( new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ) ); - out = reinterpret( new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ) ); - expected = reinterpret( new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 0ca60ea..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( val ) { - return val; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 2ef298762c483bd7fad903abea44ae1204f56e93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 11:58:43 +0000 Subject: [PATCH 03/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4ea54e0..cfe1d4f 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 039ed8275f3ebe12a7686b57d768580896f1abfd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:06:06 +0000 Subject: [PATCH 04/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 689dd79..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array2D, Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Array2D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a mask to a provided input array and returns a new array after applying a mapping function. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback to invoke - * @param thisArg - execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and mapping function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback to invoke - * @param thisArg - execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Applies a mask to a provided input array and returns a new array after applying a mapping function. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback to invoke -* @param thisArg - execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 38b42db..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 9a05992e1fcbe147373c54c884739ddf39ea37aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:06:24 +0000 Subject: [PATCH 05/22] Auto-generated commit --- .editorconfig | 181 - .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 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 259 -- examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 325 -- test/test.js | 41 - test/test.main.js | 158 - 47 files changed, 4873 insertions(+), 4922 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 .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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 = false - -# 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 2733e7b..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/array/base/mskfilter-map) 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/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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index 7cfdbfb..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 29e5a06..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index d0b366d..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, fcn[, thisArg] ) - Applies a mask and mapping function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 38f6761..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,259 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 bbf5f50..689dd79 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array2D, Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d49eb7c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72b1b06 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 1d5f28d..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,325 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = reinterpret(new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ) ); - - mask = [ 1, 0 ]; - out = reinterpret( zeros( 1, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 1.0, 4.0, 25.0, 36.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 0, 0 ]; - out = reinterpret( zeros( 0, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 0, 1 ]; - out = reinterpret( zeros( 1, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 9.0, 16.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 1, 1 ]; - out = reinterpret( zeros( 3, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = reinterpret( new Complex64Array( [ 1.0, 4.0, 9.0, 16.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = [ 1, 0 ]; - out = reinterpret( zeros( 3, 'complex64' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = reinterpret( new Complex64Array( [ 0.0, 0.0, 1.0, 4.0 ] ) ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all element equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = reinterpret( new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ) ); - out = reinterpret( new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ) ); - expected = reinterpret( new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } - - function clbk( val ) { - return val * val; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 0ca60ea..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( val ) { - return val; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( val ) { - return val * val; - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 34e620bd756781f18d48b8fafbe8a58b2ca806df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:08:13 +0000 Subject: [PATCH 06/22] 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 454803e..1406c0e 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@esm/index.mjs'; +import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@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/array-base-mskfilter-map@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@v0.1.0-esm/index.mjs'; ``` #### mskfilterMap( x, mask, clbk\[, thisArg] ) @@ -159,7 +159,7 @@ The function supports the following parameters: import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import bernoulli from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-bernoulli@esm/index.mjs'; import abs2 from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs2@esm/index.mjs'; -import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@esm/index.mjs'; +import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@v0.1.0-esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 6155d919ee3d1da4b8421fe7fc8275a366e35c7f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:08:14 +0000 Subject: [PATCH 07/22] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1406c0e..ca9c692 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@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/array-base-mskfilter-map/tags). For example, + ```javascript import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@v0.1.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfi You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@v0.1.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@esm/index.mjs'; ``` #### mskfilterMap( x, mask, clbk\[, thisArg] ) @@ -159,7 +164,7 @@ The function supports the following parameters: import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import bernoulli from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-bernoulli@esm/index.mjs'; import abs2 from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs2@esm/index.mjs'; -import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@v0.1.0-esm/index.mjs'; +import mskfilterMap from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter-map@esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 36a9933b006bacb1bd6748ed2bc7383fac60c690 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:52:17 +0000 Subject: [PATCH 08/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3659103..1bc2249 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6e95b2b34129eac46fa084f0d264b5becc6ccef7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:53:27 +0000 Subject: [PATCH 09/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 689dd79..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array2D, Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Array2D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a mask to a provided input array and returns a new array after applying a mapping function. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback to invoke - * @param thisArg - execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and mapping function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback to invoke - * @param thisArg - execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Applies a mask to a provided input array and returns a new array after applying a mapping function. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback to invoke -* @param thisArg - execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d49eb7c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 2c696a1e85fd6066b2aa3f7c494cf85c354c04c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:53:45 +0000 Subject: [PATCH 10/22] Auto-generated commit --- .editorconfig | 181 - .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 | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 84 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 260 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 311 -- test/test.js | 41 - test/test.main.js | 158 - 48 files changed, 4873 insertions(+), 5048 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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +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 -insert_final_newline = false - -# 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 2733e7b..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/array/base/mskfilter-map) 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/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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index a95ec4b..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c36b855..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index a64b94c..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 45029b4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 708c4f8..4121f18 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fba014c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6bffc57 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 7c50c84..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 95993db..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 71553f76ab3090704a00b0e813c51bc298296361 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:42:23 +0000 Subject: [PATCH 11/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3659103..1bc2249 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ade8b76deea76949be79866cad12c558cb39bbce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:25:17 +0000 Subject: [PATCH 12/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 4121f18..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Collection ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and a callback function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fba014c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 7b3612b53ca8116fff5f045b7258f658de3033a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:25:45 +0000 Subject: [PATCH 13/22] 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 | 84 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 260 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 311 -- test/test.js | 41 - test/test.main.js | 158 - 49 files changed, 4873 insertions(+), 5052 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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4e13b2a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:29:14.848Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8e73eed..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/array/base/mskfilter-map) 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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index a95ec4b..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c36b855..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index a64b94c..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 45029b4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 708c4f8..4121f18 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fba014c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6bffc57 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 7c50c84..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 95993db..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 3245484af5b4f3d0cd704e22fc14ba1e80592da3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:24:15 +0000 Subject: [PATCH 14/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3659103..1bc2249 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 08ea587e18727e8dbf86759368d2d622b6c0e710 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:54:39 +0000 Subject: [PATCH 15/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 4121f18..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Collection ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and a callback function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fba014c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From f84902dd7c7d68c7bc87bf0c0473ebdb8587971e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:55:05 +0000 Subject: [PATCH 16/22] 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 | 84 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 260 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 311 -- test/test.js | 41 - test/test.main.js | 158 - 49 files changed, 4873 insertions(+), 5052 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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 89fd734..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T01:14:58.669Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8e73eed..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/array/base/mskfilter-map) 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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index a95ec4b..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c36b855..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index a64b94c..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 45029b4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 708c4f8..4121f18 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fba014c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6bffc57 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 7c50c84..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 95993db..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From d8bbb3a2357ad7181a5ed935b0dcd07ebb0f9a93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:34:24 +0000 Subject: [PATCH 17/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3659103..1bc2249 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 48cd2887f4724b1f63d0637ff61c59d93718743c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 02:12:49 +0000 Subject: [PATCH 18/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 4121f18..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Collection ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and a callback function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fba014c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From e995020eb11ec4cdc42ca5f4cade3c1a506abc2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 02:13:21 +0000 Subject: [PATCH 19/22] 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 | 84 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 260 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 311 -- test/test.js | 41 - test/test.main.js | 158 - 49 files changed, 4873 insertions(+), 5052 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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 51457f9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T01:25:31.684Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8e73eed..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/array/base/mskfilter-map) 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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index a95ec4b..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c36b855..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index a64b94c..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 45029b4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 708c4f8..4121f18 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fba014c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6bffc57 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 7c50c84..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 95993db..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From f2b57b5deeb3f0cf57af21b9ea4dd7f5e40b9fb9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:19:59 +0000 Subject: [PATCH 20/22] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3659103..1bc2249 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "@stdlib/array-base-arraylike2object": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.2", @@ -99,4 +100,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7524a3b0be44c0b5a7262cf909669478906a9a14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:45:00 +0000 Subject: [PATCH 21/22] Remove files --- index.d.ts | 166 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5013 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 4121f18..0000000 --- a/index.d.ts +++ /dev/null @@ -1,166 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Collection ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and a callback function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fba014c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 976a9b13d987aed9bf34daa1334235992ec63e20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:45:31 +0000 Subject: [PATCH 22/22] 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 | 84 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 106 - benchmark/benchmark.js | 56 - benchmark/benchmark.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 84 - docs/types/test.ts | 260 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 182 - lib/index.js | 71 - lib/main.js | 71 - package.json | 74 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 311 -- test/test.js | 41 - test/test.main.js | 158 - 49 files changed, 4873 insertions(+), 5052 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.assign.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0a9ec59..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:16:18.703Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8e73eed..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/array/base/mskfilter-map) 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 53446d9..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/array/base/mskfilter-map) 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 53132ae..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: '59 11 * * 4' - - # 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 + + ```
@@ -204,7 +201,7 @@ console.log( 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]. 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.assign.length.js b/benchmark/benchmark.assign.length.js deleted file mode 100644 index a95ec4b..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/array-zeros' ); -var ones = require( '@stdlib/array-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isnan = require( '@stdlib/assert-is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c36b855..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index a64b94c..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ones = require( '@stdlib/array-base-ones' ); -var isArray = require( '@stdlib/assert-is-array' ); -var identity = require( '@stdlib/utils-identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4a479fd..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/array/base/mskfilter-map" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter-map -[production-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter-map/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter-map/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 4c0c52e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilterMap from '../docs/types/index'; -export = mskfilterMap; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2daf9bb..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var P=q(function(B,m){ -var h=require('@stdlib/array-base-resolve-getter/dist');function G(a,e,s,v){var c,i,o,r;for(c=h(a),i=h(e),o=[],r=0;r var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 45029b4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,260 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index dbdf243..0000000 --- a/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 zeroTo = require( '@stdlib/array-base-zero-to' ); -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var abs2 = require( '@stdlib/math-base-special-abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( 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 708c4f8..4121f18 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fba014c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,t,o){var a,n,c,l;for(a=s(r),n=s(e),c=[],l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -100,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6bffc57 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 7c50c84..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d30c04f..0000000 --- a/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasMethod = require( '@stdlib/assert-is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 95993db..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( '@stdlib/array-complex64' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -});