From ef6e99a6639fd830dc53b5b367c3cfaadd86e3d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Mar 2024 21:15:49 +0000 Subject: [PATCH 01/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d738f36..ef216d0 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.1", "@stdlib/array-base-resolve-getter": "^0.2.1", "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -88,4 +89,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4ec0e1c94a45b5c94f7754fa0b47a3275d7e0c4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Mar 2024 21:16:59 +0000 Subject: [PATCH 02/73] 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 | 229 - .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.length.js | 100 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 32 - docs/types/test.ts | 42 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 163 - package.json | 64 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 231 - 42 files changed, 4865 insertions(+), 4006 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.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 (96%) 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 e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -178,7 +169,7 @@ console.log( n ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 7d75cda..0000000 --- a/benchmark/benchmark.length.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 bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, function predicate( v ) { - return v === 1; - } ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e63bbec..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var o=v(function(C,u){ -var l=require('@stdlib/array-base-assert-is-complex-typed-array/dist'),c=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist'),s=require('@stdlib/strided-base-reinterpret-complex/dist');function q(r,e,a){var n,i;for(n=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array that satisfy the provided testing function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* function predicate( value ) {\n* return ( value % 2 === 0 )\n* }\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAsB,QAAS,kDAAmD,EAClFC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAc,QAAS,0CAA2C,EAsBtE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAI,EACA,EAGJ,IADA,EAAI,EACE,EAAI,EAAG,EAAIF,EAAE,OAAQ,IACrBC,EAAU,KAAMC,EAASF,EAAG,CAAE,EAAG,EAAGA,CAAE,IAC1C,GAAK,GAGP,OAAO,CACR,CAqBA,SAASG,EAAWH,EAAGC,EAAWC,EAAU,CAC3C,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMP,EAAeG,CAAE,EAEvBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAE,OAAQM,IACrBL,EAAU,KAAMC,EAASE,EAAKJ,EAAGM,CAAE,EAAGA,EAAGN,CAAE,IAC/CK,GAAK,GAGP,OAAOA,CACR,CAqBA,SAASE,EAASP,EAAGC,EAAWC,EAAU,CACzC,IAAIM,EACAH,EACAC,EAKJ,IAHAE,EAAOV,EAAaE,EAAG,CAAE,EAEzBK,EAAI,EACEC,EAAI,EAAGA,EAAIE,EAAK,OAAQF,GAAK,GAC7BL,EAAU,KAAMC,EAASM,EAAMF,CAAE,EAAGA,EAAGE,CAAK,GAAKP,EAAU,KAAMC,EAASM,EAAMF,EAAE,CAAE,EAAGA,EAAE,EAAGE,CAAK,KACrGH,GAAK,GAGP,OAAOA,CACR,CAqBA,SAASI,EAAST,EAAGC,EAAWC,EAAU,CACzC,OAAKN,EAAiBI,CAAE,EAClBL,EAAqBK,CAAE,EACpBO,EAASP,EAAGC,EAAWC,CAAQ,EAEhCC,EAAWH,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAR,EAAO,QAAUe,IC1HjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexTypedArray", "isAccessorArray", "resolveGetter", "reinterpret", "indexed", "x", "predicate", "thisArg", "accessors", "get", "n", "i", "complex", "view", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 457b118..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array that satisfy the provided testing - function. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Testing function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Number of truthy values for which the testing function evaluates to - true. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ], function predicate( v ) { - ... return v === 1; - ... } ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 44fb086..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,42 +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 countIf from './index'; - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], () => { return true } ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection or the function is not boolean returning... -{ - countIf( [ 5 ], function() { return 1 } ); // $ExpectError - countIf( true ); // $ExpectError - countIf( false, function() { return false} ); // $ExpectError - countIf( null ); // $ExpectError - countIf( [ {}, {} ], ()=>{} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index e29eb9e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +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 bernoulli = require( '@stdlib/random-array-bernoulli' ); -var countIf = require( './../lib' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var threshold = 0; - -function predicate( val ) { - return val === 1; -} - -var n = countIf( x, predicate, threshold ); -console.log( n ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 719556a..f54c1a0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..05dc6b5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-typed-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function n(n,a,i){return e(n)?r(n)?function(r,e,t){var n,a,i;for(n=s(r,0),a=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import Complex128Array from '@stdlib/array-complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","isComplexTypedArray","view","n","i","reinterpret","length","call","complex","get","resolveGetter","accessors","indexed"],"mappings":";;gbAqJA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAChBI,EAAqBJ,GArC5B,SAAkBA,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EACAC,EAKJ,IAHAF,EAAOG,EAAaR,EAAG,GAEvBM,EAAI,EACEC,EAAI,EAAGA,EAAIF,EAAKI,OAAQF,GAAK,GAC7BN,EAAUS,KAAMR,EAASG,EAAME,GAAKA,EAAGF,IAAUJ,EAAUS,KAAMR,EAASG,EAAME,EAAE,GAAKA,EAAE,EAAGF,MAChGC,GAAK,GAGP,OAAOA,CACR,CAwBUK,CAASX,EAAGC,EAAWC,GAzEjC,SAAoBF,EAAGC,EAAWC,GACjC,IAAIU,EACAN,EACAC,EAKJ,IAHAK,EAAMC,EAAeb,GAErBM,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASU,EAAKZ,EAAGO,GAAKA,EAAGP,KAC7CM,GAAK,GAGP,OAAOA,CACR,CA6DSQ,CAAWd,EAAGC,EAAWC,GA3GlC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAII,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASF,EAAGO,GAAKA,EAAGP,KACxCM,GAAK,GAGP,OAAOA,CACR,CAkGQS,CAASf,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 10f9bc0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array that satisfy the provided testing function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* function predicate( value ) { -* return ( value % 2 === 0 ) -* } -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bd38879..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +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 isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var x = [ 0, 1, 0, 1 ]; -* function predicate( v ) { -* return v > 0; -* } -* var n = indexed( x, predicate ); -* // returns 2 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 1 ] ); -* function predicate( v ) { -* return v > 0; -* } -* var n = accessors( x, predicate ); -* // returns 2 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a complex array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* function predicate( v ) { -* return v > 0; -* } -* var n = complex( x, predicate ); -* // returns 2 -*/ -function complex( x, predicate, thisArg ) { - var view; - var n; - var i; - - view = reinterpret( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array that satisfy the provided testing function. -* -* @param {Collection} x - input array -* @param {Function} predicate - testing array -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* function predicate( v ) { -* return v > 0; -* } -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, predicate, thisArg ); - } - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index ef216d0..684631e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Count the number of elements in an array that satisfy the provided testing function.", "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,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^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", "stdtypes", @@ -89,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..f8339d0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 4d978f0..0000000 --- a/test/test.js +++ /dev/null @@ -1,231 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var countIf = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 3; - actual = countIf( x, function predicate( v ) { - return ( v % 2 === 0 ); - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray([ 0, 1, 0, 1, 2 ]); - expected = 2; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array([ 0, 1, 0, 1, 2 ]); - expected = 1; - actual = countIf( x, function predicate( v ) { - return v > 1; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array([ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ]); - expected = 3; - actual = countIf( x, function predicate( v ) { - return v === 0; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns zero if provided an array of length `0`', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = []; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns zero if no truthy values are found', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the length of the array if all values are truthy', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - expected = x.length; - - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a custom execution context', function test( t ) { - var expected; - var context; - var actual; - var x; - - context = { - 'threshold': 2 - }; - x = [ 1, 2, 3, 4, 5 ]; - expected = 3; // Only values greater than 2 - actual = countIf( x, function predicate( v ) { - return v > this.threshold; // eslint-disable-line no-invalid-this - }, context ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function counts the number of objects with a custom predicate function using `thisArg`', function test( t ) { - var expected; - var thisArg; - var actual; - var x; - - thisArg = { - 'target': 20 - }; - x = [ - { - 'name': 'John', - 'value': 10 - }, - { - 'name': 'Jane', - 'value': 20 - }, - { - 'name': 'Doe', - 'value': 30 - } - ]; - - // Count the number of objects where the value property matches the target - expected = 1; // One object have its value property equal to 20 - actual = countIf( x, function predicate( v ) { - return v.value === this.target; // eslint-disable-line no-invalid-this - }, thisArg ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns zero if provided an array with no truthy values (false, null, undefined are treated as non truthy values)', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - x = [ false, 0, '', null, undefined ]; - actual = countIf( x, function predicate( v ) { - return v; // Returns truthy values - }); - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); From b0819434384d0bb6b7be02df73196cedd9d2bdca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:31:41 +0000 Subject: [PATCH 03/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d738f36..ef216d0 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.1", "@stdlib/array-base-resolve-getter": "^0.2.1", "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -88,4 +89,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eb3fb7e57d2d8ea3383727cda53a9302c01c0d64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:00:13 +0000 Subject: [PATCH 04/73] Remove files --- index.d.ts | 90 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4937 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 f54c1a0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,90 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of truthy values in an array. -* -* @param x - input array -* @param predicate - testing function -* @param thisArg - function context -* @returns number of values for which the provided function evaluates to true -* -* @example -* var x = [ 0, 1, 0, 1 ]; -* function predicate( v ) { -* return v > this; -* } -* var n = countIf( x, predicate, 0 ); -* // returns 2 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 05dc6b5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-typed-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function n(n,a,i){return e(n)?r(n)?function(r,e,t){var n,a,i;for(n=s(r,0),a=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import Complex128Array from '@stdlib/array-complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","isComplexTypedArray","view","n","i","reinterpret","length","call","complex","get","resolveGetter","accessors","indexed"],"mappings":";;gbAqJA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAChBI,EAAqBJ,GArC5B,SAAkBA,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EACAC,EAKJ,IAHAF,EAAOG,EAAaR,EAAG,GAEvBM,EAAI,EACEC,EAAI,EAAGA,EAAIF,EAAKI,OAAQF,GAAK,GAC7BN,EAAUS,KAAMR,EAASG,EAAME,GAAKA,EAAGF,IAAUJ,EAAUS,KAAMR,EAASG,EAAME,EAAE,GAAKA,EAAE,EAAGF,MAChGC,GAAK,GAGP,OAAOA,CACR,CAwBUK,CAASX,EAAGC,EAAWC,GAzEjC,SAAoBF,EAAGC,EAAWC,GACjC,IAAIU,EACAN,EACAC,EAKJ,IAHAK,EAAMC,EAAeb,GAErBM,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASU,EAAKZ,EAAGO,GAAKA,EAAGP,KAC7CM,GAAK,GAGP,OAAOA,CACR,CA6DSQ,CAAWd,EAAGC,EAAWC,GA3GlC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAII,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASF,EAAGO,GAAKA,EAAGP,KACxCM,GAAK,GAGP,OAAOA,CACR,CAkGQS,CAASf,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f8339d0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 08baf62d43ea5ce413ebb0c87454c929b6ab7fc8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:00:26 +0000 Subject: [PATCH 05/73] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 100 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 32 - docs/types/test.ts | 42 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 163 - package.json | 64 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 231 - 43 files changed, 4865 insertions(+), 4010 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.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 (96%) 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 ffbc1be..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:13:47.407Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -178,7 +169,7 @@ console.log( n ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 7d75cda..0000000 --- a/benchmark/benchmark.length.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 bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, function predicate( v ) { - return v === 1; - } ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e63bbec..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var o=v(function(C,u){ -var l=require('@stdlib/array-base-assert-is-complex-typed-array/dist'),c=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist'),s=require('@stdlib/strided-base-reinterpret-complex/dist');function q(r,e,a){var n,i;for(n=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array that satisfy the provided testing function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* function predicate( value ) {\n* return ( value % 2 === 0 )\n* }\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAsB,QAAS,kDAAmD,EAClFC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAc,QAAS,0CAA2C,EAsBtE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAI,EACA,EAGJ,IADA,EAAI,EACE,EAAI,EAAG,EAAIF,EAAE,OAAQ,IACrBC,EAAU,KAAMC,EAASF,EAAG,CAAE,EAAG,EAAGA,CAAE,IAC1C,GAAK,GAGP,OAAO,CACR,CAqBA,SAASG,EAAWH,EAAGC,EAAWC,EAAU,CAC3C,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMP,EAAeG,CAAE,EAEvBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAE,OAAQM,IACrBL,EAAU,KAAMC,EAASE,EAAKJ,EAAGM,CAAE,EAAGA,EAAGN,CAAE,IAC/CK,GAAK,GAGP,OAAOA,CACR,CAqBA,SAASE,EAASP,EAAGC,EAAWC,EAAU,CACzC,IAAIM,EACAH,EACAC,EAKJ,IAHAE,EAAOV,EAAaE,EAAG,CAAE,EAEzBK,EAAI,EACEC,EAAI,EAAGA,EAAIE,EAAK,OAAQF,GAAK,GAC7BL,EAAU,KAAMC,EAASM,EAAMF,CAAE,EAAGA,EAAGE,CAAK,GAAKP,EAAU,KAAMC,EAASM,EAAMF,EAAE,CAAE,EAAGA,EAAE,EAAGE,CAAK,KACrGH,GAAK,GAGP,OAAOA,CACR,CAqBA,SAASI,EAAST,EAAGC,EAAWC,EAAU,CACzC,OAAKN,EAAiBI,CAAE,EAClBL,EAAqBK,CAAE,EACpBO,EAASP,EAAGC,EAAWC,CAAQ,EAEhCC,EAAWH,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAR,EAAO,QAAUe,IC1HjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexTypedArray", "isAccessorArray", "resolveGetter", "reinterpret", "indexed", "x", "predicate", "thisArg", "accessors", "get", "n", "i", "complex", "view", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 457b118..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array that satisfy the provided testing - function. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Testing function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Number of truthy values for which the testing function evaluates to - true. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ], function predicate( v ) { - ... return v === 1; - ... } ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 44fb086..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,42 +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 countIf from './index'; - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], () => { return true } ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection or the function is not boolean returning... -{ - countIf( [ 5 ], function() { return 1 } ); // $ExpectError - countIf( true ); // $ExpectError - countIf( false, function() { return false} ); // $ExpectError - countIf( null ); // $ExpectError - countIf( [ {}, {} ], ()=>{} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index e29eb9e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +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 bernoulli = require( '@stdlib/random-array-bernoulli' ); -var countIf = require( './../lib' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var threshold = 0; - -function predicate( val ) { - return val === 1; -} - -var n = countIf( x, predicate, threshold ); -console.log( n ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 719556a..f54c1a0 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..05dc6b5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-typed-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function n(n,a,i){return e(n)?r(n)?function(r,e,t){var n,a,i;for(n=s(r,0),a=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import Complex128Array from '@stdlib/array-complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","isComplexTypedArray","view","n","i","reinterpret","length","call","complex","get","resolveGetter","accessors","indexed"],"mappings":";;gbAqJA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAChBI,EAAqBJ,GArC5B,SAAkBA,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EACAC,EAKJ,IAHAF,EAAOG,EAAaR,EAAG,GAEvBM,EAAI,EACEC,EAAI,EAAGA,EAAIF,EAAKI,OAAQF,GAAK,GAC7BN,EAAUS,KAAMR,EAASG,EAAME,GAAKA,EAAGF,IAAUJ,EAAUS,KAAMR,EAASG,EAAME,EAAE,GAAKA,EAAE,EAAGF,MAChGC,GAAK,GAGP,OAAOA,CACR,CAwBUK,CAASX,EAAGC,EAAWC,GAzEjC,SAAoBF,EAAGC,EAAWC,GACjC,IAAIU,EACAN,EACAC,EAKJ,IAHAK,EAAMC,EAAeb,GAErBM,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASU,EAAKZ,EAAGO,GAAKA,EAAGP,KAC7CM,GAAK,GAGP,OAAOA,CACR,CA6DSQ,CAAWd,EAAGC,EAAWC,GA3GlC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAII,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASF,EAAGO,GAAKA,EAAGP,KACxCM,GAAK,GAGP,OAAOA,CACR,CAkGQS,CAASf,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 10f9bc0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array that satisfy the provided testing function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* function predicate( value ) { -* return ( value % 2 === 0 ) -* } -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index bd38879..0000000 --- a/lib/main.js +++ /dev/null @@ -1,163 +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 isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var x = [ 0, 1, 0, 1 ]; -* function predicate( v ) { -* return v > 0; -* } -* var n = indexed( x, predicate ); -* // returns 2 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 1 ] ); -* function predicate( v ) { -* return v > 0; -* } -* var n = accessors( x, predicate ); -* // returns 2 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a complex array that satisfy the provided testing function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - testing function -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* function predicate( v ) { -* return v > 0; -* } -* var n = complex( x, predicate ); -* // returns 2 -*/ -function complex( x, predicate, thisArg ) { - var view; - var n; - var i; - - view = reinterpret( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array that satisfy the provided testing function. -* -* @param {Collection} x - input array -* @param {Function} predicate - testing array -* @param {*} [thisArg] - function context -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* function predicate( v ) { -* return v > 0; -* } -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, predicate, thisArg ); - } - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index ef216d0..684631e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Count the number of elements in an array that satisfy the provided testing function.", "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,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/strided-base-reinterpret-complex": "^0.1.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^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", "stdtypes", @@ -89,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..f8339d0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 4d978f0..0000000 --- a/test/test.js +++ /dev/null @@ -1,231 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var countIf = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 3; - actual = countIf( x, function predicate( v ) { - return ( v % 2 === 0 ); - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray([ 0, 1, 0, 1, 2 ]); - expected = 2; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array([ 0, 1, 0, 1, 2 ]); - expected = 1; - actual = countIf( x, function predicate( v ) { - return v > 1; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values based on a testing function (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array([ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ]); - expected = 3; - actual = countIf( x, function predicate( v ) { - return v === 0; - }); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns zero if provided an array of length `0`', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = []; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([]); - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns zero if no truthy values are found', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the length of the array if all values are truthy', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - expected = x.length; - - actual = countIf( x, function predicate( v ) { - return v === 1; - }); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a custom execution context', function test( t ) { - var expected; - var context; - var actual; - var x; - - context = { - 'threshold': 2 - }; - x = [ 1, 2, 3, 4, 5 ]; - expected = 3; // Only values greater than 2 - actual = countIf( x, function predicate( v ) { - return v > this.threshold; // eslint-disable-line no-invalid-this - }, context ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function counts the number of objects with a custom predicate function using `thisArg`', function test( t ) { - var expected; - var thisArg; - var actual; - var x; - - thisArg = { - 'target': 20 - }; - x = [ - { - 'name': 'John', - 'value': 10 - }, - { - 'name': 'Jane', - 'value': 20 - }, - { - 'name': 'Doe', - 'value': 30 - } - ]; - - // Count the number of objects where the value property matches the target - expected = 1; // One object have its value property equal to 20 - actual = countIf( x, function predicate( v ) { - return v.value === this.target; // eslint-disable-line no-invalid-this - }, thisArg ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns zero if provided an array with no truthy values (false, null, undefined are treated as non truthy values)', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - x = [ false, 0, '', null, undefined ]; - actual = countIf( x, function predicate( v ) { - return v; // Returns truthy values - }); - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); From 479c3ee5f0ec3d0b91e104c8596b64742b176c5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Apr 2024 21:05:25 +0000 Subject: [PATCH 06/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9c07120..555b896 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 09a2e5324920305d3424bb482805fdb3a20ef648 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Apr 2024 21:05:50 +0000 Subject: [PATCH 07/73] Remove files --- index.d.ts | 90 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4937 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 f54c1a0..0000000 --- a/index.d.ts +++ /dev/null @@ -1,90 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of truthy values in an array. -* -* @param x - input array -* @param predicate - testing function -* @param thisArg - function context -* @returns number of values for which the provided function evaluates to true -* -* @example -* var x = [ 0, 1, 0, 1 ]; -* function predicate( v ) { -* return v > this; -* } -* var n = countIf( x, predicate, 0 ); -* // returns 2 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 05dc6b5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-complex-typed-array@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/strided-base-reinterpret-complex@v0.1.1-esm/index.mjs";function n(n,a,i){return e(n)?r(n)?function(r,e,t){var n,a,i;for(n=s(r,0),a=0,i=0;i 0;\n* }\n* var n = indexed( x, predicate );\n* // returns 2\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = accessors( x, predicate );\n* // returns 2\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that satisfy the provided testing function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - testing function\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true\n*\n* @example\n* import Complex128Array from '@stdlib/array-complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = complex( x, predicate );\n* // returns 2\n*/\nfunction complex( x, predicate, thisArg ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that satisfy the provided testing function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - testing array\n* @param {*} [thisArg] - function context\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n* function predicate( v ) {\n*\treturn v > 0;\n* }\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, predicate, thisArg );\n\t\t}\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","isComplexTypedArray","view","n","i","reinterpret","length","call","complex","get","resolveGetter","accessors","indexed"],"mappings":";;gbAqJA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAChBI,EAAqBJ,GArC5B,SAAkBA,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EACAC,EAKJ,IAHAF,EAAOG,EAAaR,EAAG,GAEvBM,EAAI,EACEC,EAAI,EAAGA,EAAIF,EAAKI,OAAQF,GAAK,GAC7BN,EAAUS,KAAMR,EAASG,EAAME,GAAKA,EAAGF,IAAUJ,EAAUS,KAAMR,EAASG,EAAME,EAAE,GAAKA,EAAE,EAAGF,MAChGC,GAAK,GAGP,OAAOA,CACR,CAwBUK,CAASX,EAAGC,EAAWC,GAzEjC,SAAoBF,EAAGC,EAAWC,GACjC,IAAIU,EACAN,EACAC,EAKJ,IAHAK,EAAMC,EAAeb,GAErBM,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASU,EAAKZ,EAAGO,GAAKA,EAAGP,KAC7CM,GAAK,GAGP,OAAOA,CACR,CA6DSQ,CAAWd,EAAGC,EAAWC,GA3GlC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAII,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIP,EAAES,OAAQF,IACrBN,EAAUS,KAAMR,EAASF,EAAGO,GAAKA,EAAGP,KACxCM,GAAK,GAGP,OAAOA,CACR,CAkGQS,CAASf,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f8339d0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1e9fc2378f1a564cdbe1ef5be334b8dd26d381b2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Apr 2024 21:06:56 +0000 Subject: [PATCH 08/73] 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 | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 42 files changed, 4867 insertions(+), 4032 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.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 (96%) 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 e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4e9044a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 555b896..a06efa4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^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", "stdtypes", @@ -92,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..19ee669 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 4d0ff58..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From d108b62b9e105b677ad959fafa97100ccd56b885 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Apr 2024 21:07:16 +0000 Subject: [PATCH 09/73] Update README.md for ESM bundle v0.0.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3cbd3d7..7a2dc10 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.0.0-esm/index.mjs'; ``` #### countIf( x, predicate\[, thisArg] ) @@ -126,7 +126,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.0.0-esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 9d3449f8c4fc6ecd347c39f7b9d6dbddc75ea4c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Apr 2024 21:07:17 +0000 Subject: [PATCH 10/73] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a2dc10..a02fe91 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@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-count-if/tags). For example, + ```javascript import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.0.0-esm/index.mjs'; ``` @@ -126,7 +131,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.0.0-esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 20d0d84dd880228152255f83e30f91d4c19c3849 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:47:01 +0000 Subject: [PATCH 11/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9c07120..555b896 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1babb64cff9ddfdffbfc03dcb9a90f383301d67c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:08:00 +0000 Subject: [PATCH 12/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4e9044a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 19ee669..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b208b605897ee02755af871afdcbed668f2f49bc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:08:16 +0000 Subject: [PATCH 13/73] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 42 files changed, 4867 insertions(+), 4034 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.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 (96%) 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 e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4e9044a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 555b896..a06efa4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^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", "stdtypes", @@ -92,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..19ee669 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 4d0ff58..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 0d985b7d5f2427527c47999722fd0ae49c49b754 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Apr 2024 01:55:31 +0000 Subject: [PATCH 14/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f8d0475..97385e0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6da115b988d5b9a8048780eacff99cb4a2bc418f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Apr 2024 02:21:44 +0000 Subject: [PATCH 15/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4e9044a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 19ee669..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 40f4c9b44dd1ac3d15b777f9c8ef374281dc278c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Apr 2024 02:22:08 +0000 Subject: [PATCH 16/73] 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 | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 42 files changed, 4867 insertions(+), 4024 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.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 (96%) 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 e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4e9044a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 97385e0..2132f57 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^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", "stdtypes", @@ -92,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..19ee669 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 4d0ff58..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From b396fa82077521569483477f7855aec59961fac3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Apr 2024 02:25:20 +0000 Subject: [PATCH 17/73] 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 5025b64..3282681 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.0-esm/index.mjs'; ``` #### countIf( x, predicate\[, thisArg] ) @@ -126,7 +126,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.0-esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From a8318b17f0e860114d5954c457fc45d9f98778d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Apr 2024 02:25:21 +0000 Subject: [PATCH 18/73] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3282681..b860a2e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@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-count-if/tags). For example, + ```javascript import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.0-esm/index.mjs'; ``` @@ -126,7 +131,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.0-esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 9d0861cfee0c4ae1311aac60a87abb48be63b499 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:15:03 +0000 Subject: [PATCH 19/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 686887e..77d8cdc 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.1", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 27ff7d243d339f7beb5a7b5ac01234beb92ae8a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:40:32 +0000 Subject: [PATCH 20/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4e9044a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 19ee669..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From da101339dbc48299e524354d3d4b80e0d63f115e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:40:48 +0000 Subject: [PATCH 21/73] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 42 files changed, 4867 insertions(+), 4150 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.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 (96%) 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 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 e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b2a9a03 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 77d8cdc..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..0f59d1b --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From ea0e5a37e04426fdda62c9df606673a6c912a050 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:49:13 +0000 Subject: [PATCH 22/73] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f95a24..d54d052 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.1-esm/index.mjs'; ``` #### countIf( x, predicate\[, thisArg] ) @@ -126,7 +126,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.1-esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 6c2f143205dea9f23b06f5d4b3fb606f4583c012 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:49:14 +0000 Subject: [PATCH 23/73] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d54d052..2b93fac 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@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-count-if/tags). For example, + ```javascript import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.1-esm/index.mjs'; ``` @@ -126,7 +131,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.1-esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 2d17c9bfd39e76d7583e53d075aa09e19b3a848a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:22:43 +0000 Subject: [PATCH 24/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 47678e8..36536a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 487228d118f5da59332e0e5d127a49713f0bf57f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:18:40 +0000 Subject: [PATCH 25/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b2a9a03..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.1-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0f59d1b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7ce327e418a71432c09fa2d712e98e2a858e6e43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:18:57 +0000 Subject: [PATCH 26/73] 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 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 58 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 43 files changed, 4867 insertions(+), 4101 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.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 (96%) 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 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 8fcf887..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:06:49.047Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7451cf0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 36536a3..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..cb0085e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 977d048717b6f3584833c46d45c07275798e0f61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:44:48 +0000 Subject: [PATCH 27/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ff405d1..e0c158a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d6f995797a7d6dfce3495466107897c908acbb45 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:16:10 +0000 Subject: [PATCH 28/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7451cf0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb0085e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 10e93f8102a44177b9fc1e9b03db5c6585c0c02a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:16:25 +0000 Subject: [PATCH 29/73] 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 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 43 files changed, 4867 insertions(+), 4151 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.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 (96%) 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 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 59824f2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:34:46.358Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e91a8b4..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7451cf0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index e0c158a..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..cb0085e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From e8155b39789f027f036c1512bc49c55aff6d25f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:55:13 +0000 Subject: [PATCH 30/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2794784..ed20756 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0d999b61d4fc944926eeb417f86d4b04fa3e2a00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:56:53 +0000 Subject: [PATCH 31/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7451cf0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb0085e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bdd102e30cf1dc016bb2265eb6deddfa6c3c5766 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:57:18 +0000 Subject: [PATCH 32/73] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4259 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.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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 46cd6e6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T01:38:16.863Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db3d957 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index ed20756..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..cb0085e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 1f17daf82b54ccb144143ee0cf4a2c68639c6372 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 11 Aug 2025 01:40:34 +0000 Subject: [PATCH 33/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2794784..ed20756 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 68023e059ae98384e54c285a4cd53ffe1d6ca405 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 11 Aug 2025 02:04:02 +0000 Subject: [PATCH 34/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db3d957..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb0085e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 64d7050d35224b432ea1e016eb7e29d336cc7ed1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 11 Aug 2025 02:04:31 +0000 Subject: [PATCH 35/73] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4259 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.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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 970501f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-08-11T01:32:46.664Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # 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 + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db3d957 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index ed20756..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..cb0085e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 9072f56f764fa7c85b21bd38bc9526429c9c465f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 01:43:38 +0000 Subject: [PATCH 36/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1cd7801..c868139 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cda206bc2c6d074bf0e14f00ea21617afb32c40d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 02:37:36 +0000 Subject: [PATCH 37/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db3d957..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb0085e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fb9767792d131d3b387d486ca1071345b9a308e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 02:38:00 +0000 Subject: [PATCH 38/73] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 43 files changed, 4867 insertions(+), 4363 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.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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7fc0a01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index c868139..e9427a0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..cb0085e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From ad3692a309340734aa6362e52f5415cf2d51db5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 18:10:24 +0000 Subject: [PATCH 39/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f10bc74..f68c0e8 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.2", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 86ea4faaeaeabb9746328ae59658d5c19bc04d8b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 19:07:51 +0000 Subject: [PATCH 40/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7fc0a01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb0085e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 86434dee186787e34fbb23bea7cea64e4f25d98f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 19:08:11 +0000 Subject: [PATCH 41/73] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 43 files changed, 4867 insertions(+), 4366 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.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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4fcbf34 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index f68c0e8..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.1", - "@stdlib/random-array-discrete-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..4d2c21c --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 40249828dcd00a987d5ce434f0adb3b984074749 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 19:33:18 +0000 Subject: [PATCH 42/73] Update README.md for ESM bundle v0.1.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8312c0e..452f190 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.2-esm/index.mjs'; ``` #### countIf( x, predicate\[, thisArg] ) @@ -126,7 +126,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.2-esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 99c28a1ffc7dfe195ecee8bf3d1d7c920b691c27 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 19:33:19 +0000 Subject: [PATCH 43/73] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 452f190..2d19cf4 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@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-count-if/tags). For example, + ```javascript import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.2-esm/index.mjs'; ``` @@ -126,7 +131,7 @@ var cnt = context.count; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@esm/index.mjs'; var isPositiveInteger = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer' ).isPrimitive; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; -import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@v0.1.2-esm/index.mjs'; +import countIf from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-count-if@esm/index.mjs'; var x = discreteUniform( 10, -5, 5, { 'dtype': 'int32' From 8185388dd818768b2034a157975606c31bd55d0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:10:35 +0000 Subject: [PATCH 44/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cee9fda..55afabf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.3", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3cd8f863959de50e67c9f53b1bf97ec14d953f6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:25:13 +0000 Subject: [PATCH 45/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4fcbf34..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4d2c21c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 39a41bb22f50bf6fd837bd3ef1d215d59bfefcaa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:25:34 +0000 Subject: [PATCH 46/73] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4367 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.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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5c2911d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T01:05:54.706Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 55afabf..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 6d2e15cc9b61f25da7dd0e0c11a36e7873161f53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 03:04:59 +0000 Subject: [PATCH 47/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cee9fda..55afabf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.3", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From da4376943dc96cdbfc813dfb8c51fa072830b8a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 04:49:16 +0000 Subject: [PATCH 48/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b1c7678d97cf365f5c1e434636262fa4b4395bbf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 04:49:36 +0000 Subject: [PATCH 49/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4378 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d26ed98..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-23T02:24:04.026Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 55afabf..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 9ae56e30a5e45ba9b486592a57175c5493abbb68 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Apr 2026 03:25:13 +0000 Subject: [PATCH 50/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cee9fda..55afabf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.3", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4c6283fdfa836dc3385bb76fe96d84f4714e1940 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Apr 2026 03:40:09 +0000 Subject: [PATCH 51/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b4546d4a746fa1ff22d6960f3fe5bf52ce7e54df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Apr 2026 03:40:29 +0000 Subject: [PATCH 52/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4378 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1b21f69..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-03T03:19:50.200Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 55afabf..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 7085829d6b39ed8113b945a117a8a1b2db987166 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 10 May 2026 03:42:18 +0000 Subject: [PATCH 53/73] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cee9fda..55afabf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-to-accessor-array": "^0.2.3", @@ -91,4 +92,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f558342ba798d4e5d586503a05e80cc042ce6b8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 10 May 2026 04:01:08 +0000 Subject: [PATCH 54/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 97298a62f3c5039442dd7818c1dde8237fdc0e07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 10 May 2026 04:01:32 +0000 Subject: [PATCH 55/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 118 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 109 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4867 insertions(+), 4383 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 68f0c25..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-10T03:33:09.788Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 5c10cfa..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 55afabf..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -92,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..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From d4dd5d752f6ee1d13b91188d8834132a1853419a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 20:15:51 +0000 Subject: [PATCH 56/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24ab51e..ac987aa 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From 4b5d4ab2f76e4d8963339afce9dfedc0f212bcb3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 20:30:08 +0000 Subject: [PATCH 57/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b6423362a4816e0e2eb03e42a2d4721da88a24fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 20:30:31 +0000 Subject: [PATCH 58/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 43 files changed, 4866 insertions(+), 4430 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 4f96460..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index ac987aa..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 5fab2b8b028b4a349495225acea7e2600a8a438c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Jun 2026 03:32:13 +0000 Subject: [PATCH 59/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c274325..9814274 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From ff0e9e3a6733df01fc1e5a1fe589ec292fc81368 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Jun 2026 03:45:02 +0000 Subject: [PATCH 60/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f9c358c35ca1a268aa3133d9fac5677a5bfd2e84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Jun 2026 03:45:28 +0000 Subject: [PATCH 61/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4866 insertions(+), 4431 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8af00df..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-19T03:27:50.696Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d3b430b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw (e=0, t)}};};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 9814274..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 3ddc2d2e1e9ad0e207cf0a565e4ec049da47a175 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Jun 2026 03:35:37 +0000 Subject: [PATCH 62/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c274325..9814274 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From abe70dbe5bb14647546716d05c1adebc17ea3279 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Jun 2026 03:55:41 +0000 Subject: [PATCH 63/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 443105410f0c137c99d0cbe350f0a75b21502ec6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 23 Jun 2026 03:56:10 +0000 Subject: [PATCH 64/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4866 insertions(+), 4431 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 276250b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-06-23T03:29:57.414Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d3b430b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw (e=0, t)}};};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 9814274..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 34f85359149bb51b834e41b2b184f79499be3b93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 5 Aug 2026 03:41:28 +0000 Subject: [PATCH 65/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c274325..9814274 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From 9ee3c3472140edebf8b8ad90cd005e155bb42f5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 5 Aug 2026 04:03:32 +0000 Subject: [PATCH 66/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c6de18c36b69e4d1a23501545f5a3c631c47873 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 5 Aug 2026 04:03:56 +0000 Subject: [PATCH 67/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4866 insertions(+), 4431 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c068e7f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-05T03:26:54.406Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d3b430b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw (e=0, t)}};};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 9814274..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 66ca0d79d9392ca5f0c87d482da958aa3b492788 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Aug 2026 03:21:21 +0000 Subject: [PATCH 68/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c274325..9814274 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From 71841d42625f4507c139e17e1b61bdd5ae84e8f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Aug 2026 03:47:46 +0000 Subject: [PATCH 69/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From decf04a445bc6afcf682e78a5f03db2cbf9856e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Aug 2026 03:48:08 +0000 Subject: [PATCH 70/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4866 insertions(+), 4431 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7c91c40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-10T03:11:18.608Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d3b430b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw (e=0, t)}};};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 9814274..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); From 48a7de63d7f3c96b558fb4b3f72578bd1ae44fbb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Aug 2026 02:51:13 +0000 Subject: [PATCH 71/73] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c274325..9814274 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/random-array-bernoulli": "^0.2.2", "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/utils-nary-function": "^0.2.4", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", From d84a5317b5d81d216c9d75c8100b6d78a1d4abdf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Aug 2026 03:05:26 +0000 Subject: [PATCH 72/73] Remove files --- index.d.ts | 92 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4939 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 742f253..0000000 --- a/index.d.ts +++ /dev/null @@ -1,92 +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, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e569f82..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2be7af6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c15b8fb7431ee0417fe2c85859bcec25ab16d59f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 11 Aug 2026 03:05:51 +0000 Subject: [PATCH 73/73] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 153 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.length.js | 110 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 36 - docs/types/test.ts | 101 - examples/index.js | 35 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 129 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 212 - 44 files changed, 4866 insertions(+), 4432 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.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 (96%) 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 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1e723b8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-11T02:49:36.212Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 890b3c5..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/count-if) 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 e4f6969..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/count-if) 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 a0c5dfe..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: '39 3 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +173,7 @@ console.log( out ); ## 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.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 1f1b0f8..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random-array-bernoulli' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - 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( format( '%s:dtype=generic,len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 4581718..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/count-if" -%% click B href "https://github.com/stdlib-js/array-base-count-if/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-count-if/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-count-if/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-count-if/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-count-if/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/count-if -[production-url]: https://github.com/stdlib-js/array-base-count-if/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-count-if/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-count-if/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-count-if/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-count-if/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-count-if/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-count-if/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 59076d8..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import countIf from '../docs/types/index'; -export = countIf; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d3b430b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var c=function(r,e){return function(){try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw (e=0, t)}};};var s=c(function(h,a){ -var o=require('@stdlib/array-base-assert-is-accessor-array/dist'),f=require('@stdlib/array-base-resolve-getter/dist');function v(r,e,t){var i,n;for(i=0,n=0;n 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countIf;\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* Count the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-count-if\n*\n* @example\n* var countIf = require( '@stdlib/array-base-count-if' );\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 2 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAwBjE,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASF,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC1CG,GAAK,GAGP,OAAOA,CACR,CAuBA,SAASE,EAAWL,EAAGC,EAAWC,EAAU,CAC3C,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeE,CAAE,EAEvB,EAAI,EACEI,EAAI,EAAGA,EAAIJ,EAAE,OAAQI,IACrBH,EAAU,KAAMC,EAASI,EAAKN,EAAGI,CAAE,EAAGA,EAAGJ,CAAE,IAC/C,GAAK,GAGP,OAAO,CACR,CAuBA,SAASO,EAASP,EAAGC,EAAWC,EAAU,CACzC,OAAKL,EAAiBG,CAAE,EAChBK,EAAWL,EAAGC,EAAWC,CAAQ,EAElCH,EAASC,EAAGC,EAAWC,CAAQ,CACvC,CAKAN,EAAO,QAAUW,ICxFjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "resolveGetter", "indexed", "x", "predicate", "thisArg", "n", "i", "accessors", "get", "countIf", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0767c78..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f476d90..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,101 +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 toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 445794f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,35 +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 discreteUniform = require( '@stdlib/random-array-discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils-nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 1310c1a..742f253 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e569f82 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";function t(t,s,n){return r(t)?function(r,t,s){var n,a,i;for(n=e(r),a=0,i=0;i 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array-base-to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n"],"names":["countIf","x","predicate","thisArg","isAccessorArray","get","n","i","resolveGetter","length","call","accessors","indexed"],"mappings":";;kNAsHA,SAASA,EAASC,EAAGC,EAAWC,GAC/B,OAAKC,EAAiBH,GAtCvB,SAAoBA,EAAGC,EAAWC,GACjC,IAAIE,EACAC,EACAC,EAKJ,IAHAF,EAAMG,EAAeP,GAErBK,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASE,EAAKJ,EAAGM,GAAKA,EAAGN,KAC7CK,GAAK,GAGP,OAAOA,CACR,CAyBSK,CAAWV,EAAGC,EAAWC,GAzElC,SAAkBF,EAAGC,EAAWC,GAC/B,IAAIG,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIN,EAAEQ,OAAQF,IACrBL,EAAUQ,KAAMP,EAASF,EAAGM,GAAKA,EAAGN,KACxCK,GAAK,GAGP,OAAOA,CACR,CAgEQM,CAASX,EAAGC,EAAWC,EAC/B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index beb76fd..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array-base-count-if -* -* @example -* var countIf = require( '@stdlib/array-base-count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e0d3f76..0000000 --- a/lib/main.js +++ /dev/null @@ -1,129 +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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/package.json b/package.json index 9814274..954610c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/complex-float64-imag": "^0.1.2", - "@stdlib/complex-float64-real": "^0.1.2", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-bernoulli": "^0.2.2", - "@stdlib/random-array-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/utils-nary-function": "^0.2.4", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2be7af6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 293ad05..0000000 --- a/test/test.js +++ /dev/null @@ -1,212 +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 Complex128Array = require( '@stdlib/array-complex128' ); -var Int32Array = require( '@stdlib/array-int32' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -});