From 97b07eb7fdf3ee2f59bb8b4be33a0cc485aa47f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Jan 2024 02:05:16 +0000 Subject: [PATCH 01/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c5b513e..3a9d8bc 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-resolve-getter": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-ones": "^0.1.0", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 634d2687625da3cdcce16e38c67fbc13343f8254 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Jan 2024 02:06:11 +0000 Subject: [PATCH 02/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 30 - docs/types/test.ts | 57 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 65 - package.json | 62 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 100 - 43 files changed, 6201 insertions(+), 3836 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.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 (92%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 48b141b..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) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 a80a1ae..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: '42 6 * * 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -135,7 +128,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.js b/benchmark/benchmark.js deleted file mode 100644 index dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 bdac83e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index edf3ee3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=n(function(l,a){ -var v=require('@stdlib/array-base-resolve-getter/dist');function f(e,r){var s,u,i,t;for(s=v(e),u=v(r),i=[],t=0;t var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 5ba97f8..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 mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); - -console.log( x ); -console.log( mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..f53cb8f --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +31,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..325f949 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 63a3cb5..0000000 --- a/test/test.js +++ /dev/null @@ -1,100 +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 isSameValue = require( '@stdlib/complex-base-assert-is-same-value' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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( isSameValue( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 3eaa6127536da1284e3c135bd62e04fd48ffa3a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Jan 2024 02:31:51 +0000 Subject: [PATCH 03/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index afdc5e6..71093f4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-resolve-getter": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-ones": "^0.1.0", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 420be773e80201421fddd434a1fa18d09ec5b933 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Jan 2024 02:39:25 +0000 Subject: [PATCH 04/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f53cb8f..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o - - - - - - Rollup Visualizer - - - -
- - - - - From c20e7fb15ce895ec8546b8028031cdfea75c80c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 18 Jan 2024 02:39:50 +0000 Subject: [PATCH 05/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 30 - docs/types/test.ts | 57 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 65 - package.json | 62 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 100 - 43 files changed, 6201 insertions(+), 3836 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.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 (92%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 48b141b..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) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 a80a1ae..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: '42 6 * * 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -135,7 +128,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.js b/benchmark/benchmark.js deleted file mode 100644 index dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 bdac83e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index edf3ee3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=n(function(l,a){ -var v=require('@stdlib/array-base-resolve-getter/dist');function f(e,r){var s,u,i,t;for(s=v(e),u=v(r),i=[],t=0;t var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 5ba97f8..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 mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); - -console.log( x ); -console.log( mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..f53cb8f --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +31,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..b3899b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 2ae4d159754a79e4c80298e6e18d4443bfe1affc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Jan 2024 04:24:53 +0000 Subject: [PATCH 06/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ab13724..9a073ef 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-resolve-getter": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-ones": "^0.1.0", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a97d1bc944460f94ea53ca90853634f4cddf03f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Jan 2024 04:25:22 +0000 Subject: [PATCH 07/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f53cb8f..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o - - - - - - Rollup Visualizer - - - -
- - - - - From 4a96fdede09151de40ffdc1ba0758b2ff6530ed9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Jan 2024 04:26:01 +0000 Subject: [PATCH 08/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 30 - docs/types/test.ts | 57 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 65 - package.json | 62 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 100 - 43 files changed, 6201 insertions(+), 3836 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.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 (92%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 48b141b..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) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 a80a1ae..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: '42 6 * * 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -135,7 +128,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.js b/benchmark/benchmark.js deleted file mode 100644 index dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 bdac83e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +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. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index edf3ee3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=n(function(l,a){ -var v=require('@stdlib/array-base-resolve-getter/dist');function f(e,r){var s,u,i,t;for(s=v(e),u=v(r),i=[],t=0;t var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 5ba97f8..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 mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); - -console.log( x ); -console.log( mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..f53cb8f --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +31,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..e30390c --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From bd27383f1a6ca28ba431fb38c797355e9c96ee65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Jan 2024 04:26:26 +0000 Subject: [PATCH 09/61] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a92f1a..e3d10a7 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.1.0-esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -85,7 +85,7 @@ var y = mskfilter( x, [ 0, 1, 0, 1 ] ); 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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.1.0-esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From cda65a76e852687f97aaebb6cd0e90fd95a61419 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 20 Jan 2024 04:26:27 +0000 Subject: [PATCH 10/61] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e3d10a7..e013e17 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@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/tags). For example, + ```javascript import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.1.0-esm/index.mjs'; ``` @@ -85,7 +90,7 @@ var y = mskfilter( x, [ 0, 1, 0, 1 ] ); 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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.1.0-esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 36a82765669e9e423549b2dd79aecd0caee31dde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:55:54 +0000 Subject: [PATCH 11/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0f17e36..d477e5e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-resolve-getter": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-ones": "^0.1.0", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1a8872932a117b2d798d3fbc5ba8df70a7e1dcea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:19:34 +0000 Subject: [PATCH 12/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f53cb8f..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o - - - - - - Rollup Visualizer - - - -
- - - - - From ddd364e4a0d4327f3bbd5ddb8921eeb149fd3b53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:19:59 +0000 Subject: [PATCH 13/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 30 - docs/types/test.ts | 57 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 65 - package.json | 62 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 100 - 44 files changed, 6201 insertions(+), 3842 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 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.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 (92%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c36c0e0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:15:31.694Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 30656c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 3acd3a9..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 corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - 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 48b141b..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) 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 c92f5c4..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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 a80a1ae..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: '42 6 * * 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - 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 + + ```
@@ -137,7 +128,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.js b/benchmark/benchmark.js deleted file mode 100644 index dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index edf3ee3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=n(function(l,a){ -var v=require('@stdlib/array-base-resolve-getter/dist');function f(e,r){var s,u,i,t;for(s=v(e),u=v(r),i=[],t=0;t var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 5ba97f8..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 mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); - -console.log( x ); -console.log( mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..f53cb8f --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +31,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..1e2829a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 689765bd440bcfd06563b09f6b47d2a35e9278d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:00:43 +0000 Subject: [PATCH 14/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8fa8a66..5018d96 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-resolve-getter": "^0.2.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.0", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 480379ed930e2adafef5dc9cf5dc05356c1536bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:19:03 +0000 Subject: [PATCH 15/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f53cb8f..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o - - - - - - Rollup Visualizer - - - -
- - - - - From ae68837d04db9678de999532cb8f64579ca88d54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:19:58 +0000 Subject: [PATCH 16/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 30 - docs/types/test.ts | 57 - examples/index.js | 38 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 65 - package.json | 62 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 100 - 43 files changed, 6201 insertions(+), 3845 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.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 (92%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 82b4a10..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: '42 6 * * 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 corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -137,7 +128,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.js b/benchmark/benchmark.js deleted file mode 100644 index dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index edf3ee3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var o=n(function(l,a){ -var v=require('@stdlib/array-base-resolve-getter/dist');function f(e,r){var s,u,i,t;for(s=v(e),u=v(r),i=[],t=0;t var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 5ba97f8..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 mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); - -console.log( x ); -console.log( mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..f53cb8f --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +31,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..d0b0475 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From e1c019535932e8f1e1887096c71062c96c0f0c51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:17:04 +0000 Subject: [PATCH 17/61] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76581c3..5191daf 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.0-esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -85,7 +85,7 @@ var y = mskfilter( x, [ 0, 1, 0, 1 ] ); 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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.0-esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 4b89f3970a2477dd30f4792d7f29733ca1ab320d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:17:05 +0000 Subject: [PATCH 18/61] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5191daf..686a772 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@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/tags). For example, + ```javascript import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.0-esm/index.mjs'; ``` @@ -85,7 +90,7 @@ var y = mskfilter( x, [ 0, 1, 0, 1 ] ); 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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.0-esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 185955d36986906e49e7e472ef8844df699f7026 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 01:42:33 +0000 Subject: [PATCH 19/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8003f81..b82668f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.0", "@stdlib/strided-base-reinterpret-complex": "github:stdlib-js/strided-base-reinterpret-complex#main", "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4a073fb1353b47edd1f754addd8ee10ae090bd23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 01:43:05 +0000 Subject: [PATCH 20/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f53cb8f..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.1.0-esm/index.mjs";function r(r,t){var s,n,a,o;for(s=e(r),n=e(t),a=[],o=0;o - - - - - - Rollup Visualizer - - - -
- - - - - From 2361bf48c1a671053d71f51cac5a1fbbe601927b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 01:44:55 +0000 Subject: [PATCH 21/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 107 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 221 - lib/index.js | 63 - lib/main.js | 65 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 289 -- test/test.js | 41 - test/test.main.js | 100 - 47 files changed, 4872 insertions(+), 4571 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 (92%) 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -167,7 +164,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 0d2a332..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,107 +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 bernoulli = require( '@stdlib/random-array-bernoulli' ); -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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = ones( len, 'generic' ); - mask = bernoulli( len, 0.5, { - 'dtype': '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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16ee3b2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var d=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var m=d(function(z,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function b(a,t){var e,v,s,r;for(e=p(a),v=p(t),s=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAyBtE,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CA0BA,SAASe,EAAQjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIc,EACAC,EACAC,EAKJ,OAHAF,EAAKrB,EAAkBG,CAAE,EACzBmB,EAAKtB,EAAkBI,CAAK,EAC5BmB,EAAKvB,EAAkBK,CAAI,EAE1BgB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIFxB,EAAmBsB,EAAG,KAAM,GAC5BtB,EAAmBwB,EAAG,KAAM,GAE5BN,EAAShB,EAAaE,EAAG,CAAE,EAAGmB,EAAIrB,EAAaI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,IAERI,EAAWY,EAAIC,EAAIC,EAAIjB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAP,EAAO,QAAUsB,IC1KjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "arraylike2object", "reinterpret", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..4f060e1 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;siBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 13da593..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,221 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index b82668f..86d1a70 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,51 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.0", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.0", - "@stdlib/array-base-resolve-getter": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex": "github:stdlib-js/strided-base-reinterpret-complex#main", - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.0", - "@stdlib/array-base-to-accessor-array": "^0.2.0", - "@stdlib/array-base-zero-to": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-ones": "^0.2.0", - "@stdlib/array-zeros": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-method": "^0.2.0", - "@stdlib/assert-is-nan": "^0.2.0", - "@stdlib/assert-is-same-complex64": "^0.2.0", - "@stdlib/assert-is-same-complex64array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-array-bernoulli": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -99,4 +31,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..7216a79 --- /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 befd669..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,289 +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 Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From ce59186cd137282f08526ae13af57c3f9d9b48a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 03:58:02 +0000 Subject: [PATCH 22/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8003f81..b82668f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.0", "@stdlib/strided-base-reinterpret-complex": "github:stdlib-js/strided-base-reinterpret-complex#main", "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-base-ones": "^0.2.0", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ffe30775803d570774ff34c81911376fa4a3f46e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 03:58:31 +0000 Subject: [PATCH 23/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4f060e1..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;siBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7216a79..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2a864df058700054ee93e840bdd967dfc354ade4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 20 Feb 2024 04:00:37 +0000 Subject: [PATCH 24/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 221 - lib/index.js | 63 - lib/main.js | 65 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 289 -- test/test.js | 41 - test/test.main.js | 100 - 47 files changed, 4872 insertions(+), 4569 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 (92%) 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16ee3b2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var d=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var m=d(function(z,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function b(a,t){var e,v,s,r;for(e=p(a),v=p(t),s=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAyBtE,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CA0BA,SAASe,EAAQjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIc,EACAC,EACAC,EAKJ,OAHAF,EAAKrB,EAAkBG,CAAE,EACzBmB,EAAKtB,EAAkBI,CAAK,EAC5BmB,EAAKvB,EAAkBK,CAAI,EAE1BgB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIFxB,EAAmBsB,EAAG,KAAM,GAC5BtB,EAAmBwB,EAAG,KAAM,GAE5BN,EAAShB,EAAaE,EAAG,CAAE,EAAGmB,EAAIrB,EAAaI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,IAERI,EAAWY,EAAIC,EAAIC,EAAIjB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAP,EAAO,QAAUsB,IC1KjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "arraylike2object", "reinterpret", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..4f060e1 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;siBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 13da593..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,221 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index b82668f..86d1a70 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,51 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.0", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.0", - "@stdlib/array-base-resolve-getter": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex": "github:stdlib-js/strided-base-reinterpret-complex#main", - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.0", - "@stdlib/array-base-to-accessor-array": "^0.2.0", - "@stdlib/array-base-zero-to": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-ones": "^0.2.0", - "@stdlib/array-zeros": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-method": "^0.2.0", - "@stdlib/assert-is-nan": "^0.2.0", - "@stdlib/assert-is-same-complex64": "^0.2.0", - "@stdlib/assert-is-same-complex64array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-array-bernoulli": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -99,4 +31,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..7216a79 --- /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 befd669..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,289 +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 Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 4726020c7aaf9d26321849903fd848f3a3044d3e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:59:15 +0000 Subject: [PATCH 25/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9412c20..3b1c3f1 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.0", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6e23fcbdff0d417a452c46a7672672dd43825025 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:19:35 +0000 Subject: [PATCH 26/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4f060e1..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;siBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7216a79..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 58537faecaca4140040518e47856da9e4ab1f508 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:20:08 +0000 Subject: [PATCH 27/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 221 - lib/index.js | 63 - lib/main.js | 65 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 289 -- test/test.js | 41 - test/test.main.js | 100 - 47 files changed, 4872 insertions(+), 4569 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 (92%) 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16ee3b2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var d=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var m=d(function(z,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function b(a,t){var e,v,s,r;for(e=p(a),v=p(t),s=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAyBtE,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CA0BA,SAASe,EAAQjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIc,EACAC,EACAC,EAKJ,OAHAF,EAAKrB,EAAkBG,CAAE,EACzBmB,EAAKtB,EAAkBI,CAAK,EAC5BmB,EAAKvB,EAAkBK,CAAI,EAE1BgB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIFxB,EAAmBsB,EAAG,KAAM,GAC5BtB,EAAmBwB,EAAG,KAAM,GAE5BN,EAAShB,EAAaE,EAAG,CAAE,EAAGmB,EAAIrB,EAAaI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,IAERI,EAAWY,EAAIC,EAAIC,EAAIjB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAP,EAAO,QAAUsB,IC1KjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "arraylike2object", "reinterpret", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..72ddef0 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 13da593..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,221 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 3b1c3f1..0f882dd 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,51 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.0", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@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", - "@stdlib/array-base-to-accessor-array": "^0.2.0", - "@stdlib/array-base-zero-to": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-method": "^0.2.1", - "@stdlib/assert-is-nan": "^0.2.1", - "@stdlib/assert-is-same-complex64": "^0.2.1", - "@stdlib/assert-is-same-complex64array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -99,4 +31,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..0b39903 --- /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 befd669..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,289 +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 Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From a06714708af35cee1e8550684242c506e446efff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:34:23 +0000 Subject: [PATCH 28/61] Update README.md for ESM bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d3c8b5..9230942 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.1-esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -122,7 +122,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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.1-esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From fa02f4fcfd47eea9d9e5307453986519439dadd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:34:24 +0000 Subject: [PATCH 29/61] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9230942..3ba2196 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@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/tags). For example, + ```javascript import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.1-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilte 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@v0.2.1-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -122,7 +127,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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.2.1-esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From cc92a2b698fced1b5c23acf8e221f4281eefa35b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:35:01 +0000 Subject: [PATCH 30/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 66d270c..53fb9d0 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.1", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f620ee3c711f28c36f9d61894ded12d1f5d5bb62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 14:13:01 +0000 Subject: [PATCH 31/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72ddef0..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b39903..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 58eabc9ddbf258fb4733310b0514a280e543bd50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 14:13:24 +0000 Subject: [PATCH 32/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 221 - lib/index.js | 63 - lib/main.js | 65 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 289 -- test/test.js | 41 - test/test.main.js | 100 - 48 files changed, 4872 insertions(+), 4574 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 .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 (92%) 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2371eec..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:53:52.271Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16ee3b2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var d=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var m=d(function(z,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function b(a,t){var e,v,s,r;for(e=p(a),v=p(t),s=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAyBtE,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CA0BA,SAASe,EAAQjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIc,EACAC,EACAC,EAKJ,OAHAF,EAAKrB,EAAkBG,CAAE,EACzBmB,EAAKtB,EAAkBI,CAAK,EAC5BmB,EAAKvB,EAAkBK,CAAI,EAE1BgB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIFxB,EAAmBsB,EAAG,KAAM,GAC5BtB,EAAmBwB,EAAG,KAAM,GAE5BN,EAAShB,EAAaE,EAAG,CAAE,EAAGmB,EAAIrB,EAAaI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,IAERI,EAAWY,EAAIC,EAAIC,EAAIjB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAP,EAAO,QAAUsB,IC1KjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "arraylike2object", "reinterpret", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..72ddef0 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 13da593..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,221 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 53fb9d0..0f882dd 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,51 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@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", - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-method": "^0.2.1", - "@stdlib/assert-is-nan": "^0.2.1", - "@stdlib/assert-is-same-complex64": "^0.2.1", - "@stdlib/assert-is-same-complex64array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -99,4 +31,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..0b39903 --- /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 befd669..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,289 +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 Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 6901b43bf63ec2b855f1bcf0d6ca7fc6dedc342b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:39:02 +0000 Subject: [PATCH 33/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 66d270c..53fb9d0 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.1", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -98,4 +99,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b7679a01cc1e0cee91664da935ff25534af3dbf3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:24:18 +0000 Subject: [PATCH 34/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72ddef0..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b39903..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 38f9eaed37bc9e5c511b6f3fc497dc68b09be409 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:24:38 +0000 Subject: [PATCH 35/61] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .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 | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 221 - lib/index.js | 63 - lib/main.js | 65 - package.json | 74 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 289 -- test/test.js | 41 - test/test.main.js | 100 - 47 files changed, 4872 insertions(+), 4575 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 (92%) 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 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +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: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +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 }} - steps: ${{ toJson(steps) }} - 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16ee3b2..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var d=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var m=d(function(z,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function b(a,t){var e,v,s,r;for(e=p(a),v=p(t),s=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAyBtE,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CA0BA,SAASe,EAAQjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIc,EACAC,EACAC,EAKJ,OAHAF,EAAKrB,EAAkBG,CAAE,EACzBmB,EAAKtB,EAAkBI,CAAK,EAC5BmB,EAAKvB,EAAkBK,CAAI,EAE1BgB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIFxB,EAAmBsB,EAAG,KAAM,GAC5BtB,EAAmBwB,EAAG,KAAM,GAE5BN,EAAShB,EAAaE,EAAG,CAAE,EAAGmB,EAAIrB,EAAaI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,IAERI,EAAWY,EAAIC,EAAIC,EAAIjB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAP,EAAO,QAAUsB,IC1KjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "arraylike2object", "reinterpret", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..72ddef0 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 13da593..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,221 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 53fb9d0..0f882dd 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,51 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@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", - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-method": "^0.2.1", - "@stdlib/assert-is-nan": "^0.2.1", - "@stdlib/assert-is-same-complex64": "^0.2.1", - "@stdlib/assert-is-same-complex64array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -99,4 +31,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..0b39903 --- /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 befd669..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,289 +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 Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 9f8e74a..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,100 +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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 89716da851a46b7ff339dbb6dbe54d5e17f9570b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 25 Jun 2024 19:58:23 +0000 Subject: [PATCH 36/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cf1d085..4e65304 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.1", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e2749aee5d66eef8625faeadb91b1a6bf71905a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 25 Jun 2024 19:58:50 +0000 Subject: [PATCH 37/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 72ddef0..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function a(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;6iBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CCkIA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QAhEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CA4CGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,IAtHV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAIgB,EACAR,EACAS,EACA1B,EACAC,EACA0B,EACAT,EACAf,EAWJ,IATAsB,EAAQ3B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbK,EAAQxB,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBK,EAAOzB,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIsB,EAAMpB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBwB,EAAMD,EAAOR,EAAIlB,EAAMyB,EAAOtB,IAC9Be,GAAMV,EAIT,CA8FEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAlKT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAwJCoB,CAAS9B,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CC9JA2B,EAAAC,EAAA,SAAAvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b39903..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c3687e1deb1aaafd0fb43bc1d0a26e08432ef06e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 25 Jun 2024 19:59:34 +0000 Subject: [PATCH 38/61] 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 | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 97 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 -- lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 47 files changed, 4872 insertions(+), 4806 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 (92%) 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 f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..c84bf76 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4e65304..0f882dd 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.1", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@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", - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-method": "^0.2.1", - "@stdlib/assert-is-nan": "^0.2.1", - "@stdlib/assert-is-same-booleanarray": "github:stdlib-js/assert-is-same-booleanarray#main", - "@stdlib/assert-is-same-complex64": "^0.2.1", - "@stdlib/assert-is-same-complex64array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..5eb52d3 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 3a9a01433f597d94f3a60781acd111b25b0706ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 11:58:33 +0000 Subject: [PATCH 39/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c15e198..d58e863 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 746d4c93fd61bcfd9b71fc27f1e2d22c9a4fb1d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:05:45 +0000 Subject: [PATCH 40/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c84bf76..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.1-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5eb52d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9d61e7febe2a2c82df7f1a0107ca75bad42982dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:06:04 +0000 Subject: [PATCH 41/61] 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 | 149 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 -- lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 47 files changed, 4872 insertions(+), 4860 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 (92%) 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 f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..e0f5748 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index d58e863..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.3.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", - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "github:stdlib-js/assert-is-same-booleanarray#main", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 8b144859fa08d15874fd8183c2a80382996307a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:08:06 +0000 Subject: [PATCH 42/61] Update README.md for ESM bundle v0.3.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f97eb09..505faf8 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.3.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@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.3.0-esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -122,7 +122,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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.3.0-esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From 584c57e8cdfb7b88dfcf03498e9d45f5096ce543 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:08:07 +0000 Subject: [PATCH 43/61] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 505faf8..294c926 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@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/tags). For example, + ```javascript import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.3.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilte 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@v0.3.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; ``` #### mskfilter( x, mask ) @@ -122,7 +127,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 mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@v0.3.0-esm/index.mjs'; +import mskfilter from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-mskfilter@esm/index.mjs'; // Generate a linearly spaced array: var x = zeroTo( 20 ); From a439e7ef993e09bd23edb7288a3d78927c5fdca1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:13:10 +0000 Subject: [PATCH 44/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f4110e..4daa6cc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0efb6e2ce44a1e3bab8fc6772ee16052c70e4c34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:42:09 +0000 Subject: [PATCH 45/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e0f5748..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 43e99c0ec8952f86268dff02c032a4f7f4918363 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:42:41 +0000 Subject: [PATCH 46/61] Auto-generated commit --- .editorconfig | 181 - .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 | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 149 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 49 files changed, 4872 insertions(+), 4966 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 (92%) 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/.keepalive b/.github/.keepalive deleted file mode 100644 index 7a356ef..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T02:03:43.543Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 7768975..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..e0f5748 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4daa6cc..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "^0.1.0", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 9f000f639ffcc8776f95aa9cd007de226593888c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:52:22 +0000 Subject: [PATCH 47/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f4110e..4daa6cc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7ed1ea88b01b4f33b51e1d5dbbafcd56cdcc1e64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:54:12 +0000 Subject: [PATCH 48/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e0f5748..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a751b06715e24c0118ac93cfd8b4566b8f21f2bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Jan 2025 22:54:28 +0000 Subject: [PATCH 49/61] 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 | 183 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 48 files changed, 4872 insertions(+), 4999 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 (92%) 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 f05f972..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 b00a181..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..d0fcda0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4daa6cc..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "^0.1.0", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 7250e8df2462e9b6bdc84c4e1ed7b55897e94344 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:17:19 +0000 Subject: [PATCH 50/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f4110e..4daa6cc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 766cc28c81e44d718fb0e3ab8b5a6a524a121805 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 03:20:48 +0000 Subject: [PATCH 51/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d0fcda0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 546c56969222d8fcfd2b69fd3857802ee54cba8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 03:21:19 +0000 Subject: [PATCH 52/61] 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 | 183 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 49 files changed, 4872 insertions(+), 5003 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 (92%) 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 2de54d7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:56:41.195Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 592c418..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 b00a181..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..d0fcda0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4daa6cc..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "^0.1.0", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From ca74255aa2806d3875fb1be1312342fa8fcc2612 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:49:44 +0000 Subject: [PATCH 53/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f4110e..4daa6cc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 387f86264cc8af2ec50c30723a861cbc00156031 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:08:18 +0000 Subject: [PATCH 54/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d0fcda0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 120ae683770aa920c615d48bf772834701a39542 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:08:44 +0000 Subject: [PATCH 55/61] 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 | 183 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 49 files changed, 4872 insertions(+), 5003 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 (92%) 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 d77b3cb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T00:44:56.877Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 592c418..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 b00a181..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..d0fcda0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4daa6cc..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "^0.1.0", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 1dd26e2305b94dfed4c5fa5e7d3238ab92e8b664 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:11:30 +0000 Subject: [PATCH 56/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f4110e..4daa6cc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3fa0d4f04d76592bf56f6ab4bf4bee172bc99789 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:27:01 +0000 Subject: [PATCH 57/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d0fcda0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 06fb46e7da19a5b1255e4f461bf0392b7482b04a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:27:35 +0000 Subject: [PATCH 58/61] 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 | 183 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 49 files changed, 4872 insertions(+), 5003 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 (92%) 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 09adaf8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-14T01:07:18.012Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 592c418..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 b00a181..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..d0fcda0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4daa6cc..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-booleanarray": "^0.1.0", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 3989856..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isSameBooleanArray = require( '@stdlib/assert-is-same-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); From 12550f86c2f05c9d166d93a7e55e3485761f4e53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 07:44:06 +0000 Subject: [PATCH 59/61] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 556b591..4bdee03 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", "@stdlib/strided-base-reinterpret-complex": "^0.1.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", @@ -102,4 +103,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 87a752a19cabd948f2c5e0b0276abd7715b92611 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 07:44:29 +0000 Subject: [PATCH 60/61] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 17c4864..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +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'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d0fcda0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d2c946..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c0ec5791c53c4c822274060dd1f43e7e03f372b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 07:45:35 +0000 Subject: [PATCH 61/61] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 184 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.assign.length.js | 105 - benchmark/benchmark.js | 55 - benchmark/benchmark.length.js | 97 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 57 - examples/index.js | 37 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 272 - lib/index.js | 63 - lib/main.js | 65 - package.json | 78 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 349 -- test/test.js | 41 - test/test.main.js | 113 - 48 files changed, 4872 insertions(+), 5003 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 (92%) 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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 592c418..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) 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 48b141b..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) 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 b2c1f9c..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: '42 6 * * 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 + + ```
@@ -167,7 +164,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 f132c91..0000000 --- a/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter.assign( x, mask, out, 1, 0 ); - 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 dc948c9..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 a3d1ffd..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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 pkg = require( './../package.json' ).name; -var mskfilter = 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 = mskfilter( x, y ); - 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 f19c1cf..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" -%% click B href "https://github.com/stdlib-js/array-base-mskfilter/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-mskfilter/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-mskfilter/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-mskfilter/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-mskfilter/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/mskfilter -[production-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-mskfilter/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-mskfilter/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-mskfilter/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 2d0860a..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import mskfilter from '../docs/types/index'; -export = mskfilter; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 3cfa2e4..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var g=function(a,t){return function(){return t||a((t={exports:{}}).exports,t),t.exports}};var y=g(function(E,q){ -var p=require('@stdlib/array-base-resolve-getter/dist');function D(a,t){var e,v,n,r;for(e=p(a),v=p(t),n=[],r=0;r[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* var Uint8Array = require( '@stdlib/array-uint8' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* var mskfilter = require( '@stdlib/array-base-mskfilter' );\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,mCAAoC,EAmBjE,SAASC,EAAWC,EAAGC,EAAO,CAC7B,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOJ,EAAeE,CAAE,EACxBG,EAAOL,EAAeG,CAAK,EAG3BG,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIL,EAAE,OAAQK,IACrBF,EAAMF,EAAMI,CAAE,GAClBD,EAAI,KAAMF,EAAMF,EAAGK,CAAE,CAAE,EAGzB,OAAOD,CACR,CAKAP,EAAO,QAAUE,IChEjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,+DAAgE,EAC7FC,EAAoB,QAAS,gDAAiD,EAC9EC,EAAmB,QAAS,qCAAsC,EAClEC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EAyB7E,SAASC,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAIC,EACA,EAGJ,IADAA,EAAKD,EACC,EAAI,EAAG,EAAIJ,EAAE,OAAQ,IACrBC,EAAM,CAAE,IACZC,EAAKG,CAAG,EAAIL,EAAG,CAAE,EACjBK,GAAMF,GAGR,OAAOD,CACR,CA6BA,SAASI,EAAWN,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAClD,IAAIG,EACAC,EACAC,EACAC,EACAC,EACAC,EACAP,EACAQ,EAWJ,IATAN,EAAQP,EAAE,KACVQ,EAAQP,EAAK,KACbQ,EAAQP,EAAI,KAEZQ,EAAOV,EAAE,UAAW,CAAE,EACtBW,EAAOV,EAAK,UAAW,CAAE,EACzBW,EAAOV,EAAI,UAAW,CAAE,EAExBG,EAAKD,EACCS,EAAI,EAAGA,EAAIN,EAAM,OAAQM,IACzBF,EAAMH,EAAOK,CAAE,IACnBD,EAAMH,EAAOJ,EAAIK,EAAMH,EAAOM,CAAE,CAAE,EAClCR,GAAMF,GAGR,OAAOM,CACR,CAyBA,SAASK,EAASd,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAU,EACAF,EACAG,EAOJ,IALAR,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBc,EAAKZ,EAAS,EACdE,EAAKD,EAAS,EACRS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBG,EAAIH,EAAI,EACRX,EAAKG,CAAG,EAAIL,EAAGgB,CAAE,EACjBd,EAAKG,EAAG,CAAE,EAAIL,EAAGgB,EAAE,CAAE,EACrBX,GAAMU,GAGR,OAAOb,CACR,CAyBA,SAASe,EAASjB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAChD,IAAII,EACAG,EACAN,EACAQ,EAMJ,IAJAL,EAAQP,EAAK,KACbU,EAAOV,EAAK,UAAW,CAAE,EAEzBI,EAAKD,EACCS,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IACzBF,EAAMH,EAAOK,CAAE,IACnBX,EAAKG,CAAG,EAAIL,EAAGa,CAAE,EACjBR,GAAMF,GAGR,OAAOD,CACR,CA0BA,SAASgB,EAAQlB,EAAGC,EAAMC,EAAKC,EAAQC,EAAS,CAC/C,IAAIe,EACAC,EACAC,EAKJ,OAHAF,EAAKvB,EAAkBI,CAAE,EACzBoB,EAAKxB,EAAkBK,CAAK,EAC5BoB,EAAKzB,EAAkBM,CAAI,EAE1BiB,EAAG,kBACHC,EAAG,kBACHC,EAAG,iBAIF3B,EAAmByB,EAAG,KAAM,GAC5BzB,EAAmB2B,EAAG,KAAM,GAE5BP,EAASjB,EAAaG,EAAG,CAAE,EAAGoB,EAAIvB,EAAaK,EAAK,CAAE,EAAGC,EAAQC,CAAO,EACjEF,GAGPP,EAAmBwB,EAAG,KAAM,GAC5BxB,EAAmB0B,EAAG,KAAM,GAE5BJ,EAASnB,EAAoBE,EAAG,CAAE,EAAGoB,EAAItB,EAAoBI,EAAK,CAAE,EAAGC,EAAQC,CAAO,EAC/EF,IAERI,EAAWa,EAAIC,EAAIC,EAAIlB,EAAQC,CAAO,EAC/BF,IAERH,EAASC,EAAGC,EAAMC,EAAKC,EAAQC,CAAO,EAC/BF,EACR,CAKAT,EAAO,QAAUyB,IC7NjB,IAAII,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveGetter", "mskfilter", "x", "mask", "xget", "mget", "out", "i", "require_assign", "__commonJSMin", "exports", "module", "isComplexDataType", "isBooleanDataType", "arraylike2object", "reinterpret", "reinterpretBoolean", "indexed", "x", "mask", "out", "stride", "offset", "io", "accessors", "xdata", "mdata", "odata", "xget", "mget", "oset", "i", "complex", "so", "j", "boolean", "assign", "xo", "mo", "oo", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5ec073f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input 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. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values 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. - - 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 ) - [ 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 b00a181..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +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 mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 0c597de..0000000 --- a/examples/index.js +++ /dev/null @@ -1,37 +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 mskfilter = 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 = mskfilter( x, mask ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 92% rename from docs/types/index.d.ts rename to index.d.ts index a654b80..17c4864 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..d0fcda0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-floating-point-data-type@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-boolean-data-type@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-boolean@v0.0.2-esm/index.mjs";function d(e,t){var r,o,a,n;for(r=s(e),o=s(t),a=[],n=0;n[ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array-uint8';\n* import arraylike2object from '@stdlib/array-base-arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array-base-mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array-base-mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["mskfilter","x","mask","xget","mget","out","i","resolveGetter","length","push","assign","stride","offset","xo","mo","oo","arraylike2object","accessorProtocol","isComplexDataType","dtype","mdata","io","so","j","data","accessors","complex","reinterpret","isBooleanDataType","boolean","reinterpretBoolean","xdata","odata","oset","indexed","setReadOnly","main"],"mappings":";;ywBAyCA,SAASA,EAAWC,EAAGC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAQJ,IALAH,EAAOI,EAAeN,GACtBG,EAAOG,EAAeL,GAGtBG,EAAM,GACAC,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBF,EAAMF,EAAMI,IAChBD,EAAII,KAAMN,EAAMF,EAAGK,IAGrB,OAAOD,CACR,CC8KA,SAASK,EAAQT,EAAGC,EAAMG,EAAKM,EAAQC,GACtC,IAAIC,EACAC,EACAC,EAKJ,OAHAF,EAAKG,EAAkBf,GACvBa,EAAKE,EAAkBd,GACvBa,EAAKC,EAAkBX,GAEtBQ,EAAGI,kBACHH,EAAGG,kBACHF,EAAGE,iBAIFC,EAAmBL,EAAGM,QACtBD,EAAmBH,EAAGI,QA1GzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAC,EACAhB,EACAiB,EAOJ,IALAH,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBH,EAAc,EAATX,EACLU,EAAc,EAATT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBiB,EAAQ,EAAJjB,EACJD,EAAKgB,GAAOpB,EAAGsB,GACflB,EAAKgB,EAAG,GAAMpB,EAAGsB,EAAE,GACnBF,GAAMC,EAIT,CAsFGI,CAASC,EAAa1B,EAAG,GAAKa,EAAIa,EAAatB,EAAK,GAAKM,EAAQC,GAC1DP,GAGPuB,EAAmBf,EAAGM,QACtBS,EAAmBb,EAAGI,QAlEzB,SAAkBlB,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIQ,EACAhB,EACAiB,EACAf,EAMJ,IAJAc,EAAQlB,EAAKsB,KACbpB,EAAOF,EAAKuB,UAAW,GAEvBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIc,EAAMZ,OAAQF,IACzBF,EAAMgB,EAAOd,KACjBD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAmDGkB,CAASC,EAAoB7B,EAAG,GAAKa,EAAIgB,EAAoBzB,EAAK,GAAKM,EAAQC,GACxEP,IAvKV,SAAoBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACzC,IAAImB,EACAX,EACAY,EACA7B,EACAC,EACA6B,EACAZ,EACAf,EAWJ,IATAyB,EAAQ9B,EAAEuB,KACVJ,EAAQlB,EAAKsB,KACbQ,EAAQ3B,EAAImB,KAEZrB,EAAOF,EAAEwB,UAAW,GACpBrB,EAAOF,EAAKuB,UAAW,GACvBQ,EAAO5B,EAAIoB,UAAW,GAEtBJ,EAAKT,EACCN,EAAI,EAAGA,EAAIyB,EAAMvB,OAAQF,IACzBF,EAAMgB,EAAOd,KACjB2B,EAAMD,EAAOX,EAAIlB,EAAM4B,EAAOzB,IAC9Be,GAAMV,EAIT,CA+IEc,CAAWZ,EAAIC,EAAIC,EAAIJ,EAAQC,GACxBP,IAnNT,SAAkBJ,EAAGC,EAAMG,EAAKM,EAAQC,GACvC,IAAIS,EACAf,EAGJ,IADAe,EAAKT,EACCN,EAAI,EAAGA,EAAIL,EAAEO,OAAQF,IACrBJ,EAAMI,KACVD,EAAKgB,GAAOpB,EAAGK,GACfe,GAAMV,EAIT,CAyMCuB,CAASjC,EAAGC,EAAMG,EAAKM,EAAQC,GACxBP,EACR,CCjNA8B,EAAAC,EAAA,SAAA1B"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index e140fc5..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,272 +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 isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); -var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 63ab4b8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array-base-mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array-base-mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3e01481..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +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 resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/package.json b/package.json index 4bdee03..1294ac4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Apply a mask to a provided input array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,55 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", - "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.2", - "@stdlib/strided-base-reinterpret-complex": "^0.1.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-ones": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-ones": "^0.2.1", - "@stdlib/array-zeros": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-equal-booleanarray": "github:stdlib-js/assert-is-equal-booleanarray#main", - "@stdlib/assert-is-method": "^0.2.2", - "@stdlib/assert-is-nan": "^0.2.2", - "@stdlib/assert-is-same-complex64": "^0.2.2", - "@stdlib/assert-is-same-complex64array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -103,4 +31,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..6d2c946 --- /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 2c77f36..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,349 +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 BooleanArray = require( '@stdlib/array-bool' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var Int32Array = require( '@stdlib/array-int32' ); -var isSameComplex64Array = require( '@stdlib/assert-is-same-complex64array' ); -var isEqualBooleanArray = require( '@stdlib/assert-is-equal-booleanarray' ); -var zeros = require( '@stdlib/array-zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - 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' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - 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 = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - 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 = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 735df4d..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 mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 006157e..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,113 +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 BooleanArray = require( '@stdlib/array-bool' ); -var isSameComplex64 = require( '@stdlib/assert-is-same-complex64' ); -var isArray = require( '@stdlib/assert-is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, '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 = mskfilter( x, mask ); - expected = [ 2, 4 ]; - 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 = mskfilter( x, mask ); - 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 = mskfilter( x, mask ); - expected = [ 4 ]; - 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 = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -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 = mskfilter( x, mask ); - 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' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - 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( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -});