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 a8d1b69..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/bool) 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 3e54158..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/bool) 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -1883,7 +1874,7 @@ logEach( '%s', 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]. @@ -1948,9 +1939,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index d723421..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 58fa8a0..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-boolean' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < 5; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - buf = reinterpret( arr, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i%2; - arr = arr.copyWithin( 1, 0 ); - if ( typeof arr !== 'object' ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 8d3a2e7..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var reinterpret = require( '@stdlib/strided-base-reinterpret-boolean' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < len+1; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - buf = reinterpret( arr, 0 ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i%2; - arr = arr.copyWithin( 1, 0 ); - if ( typeof arr !== 'object' ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - 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:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index 6b55287..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index e650a2d..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v === true; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index 5365ce4..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,116 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index ae2bad3..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - true, - false - ]; - arr = new BooleanArray( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 18dad27..0000000 --- a/benchmark/benchmark.fill.length.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new BooleanArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 205402a..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === true ); - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index af708a6..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,116 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - 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 = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index 238da77..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.find( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 3a779bb..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === false ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 1 ) ); - } - arr.push( Boolean( 0 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.find( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - 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:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4fb691c..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index d3cb0be..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === true ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr.push( Boolean( 1 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an 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:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index db8d39f..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.findLast( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index e08ce0f..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === false ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( Boolean( 0 ) ); - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 1 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.findLast( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - 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:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 098ca6b..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index c4c4858..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === true ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( Boolean( 1 ) ); - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an 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:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index 7332667..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( check ); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function check( v ) { - if ( !isBoolean( v ) ) { - b.fail( 'should be a boolean' ); - } - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 673aaf2..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( callback ); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function callback( value ) { - if ( value !== true ) { - throw new Error( 'something went wrong' ); - } - } - } -} - - -// 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:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index bb8245f..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:from:len=5', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from:len=5', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return !v; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array:from:len=5', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from:len=5', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return !v; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable:from:len=5', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( format( '%s::iterable,clbk:from:len=5', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return !v; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 60aeacb..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c3041e7..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( true, 0 ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index 3940f6d..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( false ); - } - arr.push( true ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( true ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index a528420..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var arr; - var idx; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( false, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 1db6584..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( false ); - } - arr.push( true ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( true ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an 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:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index 36c92cb..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 60a0c6b..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.join( '/' ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index c530e1d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = BooleanArray; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index dd7838d..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new BooleanArray( [ true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index 06dd29e..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 472140b..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var arr; - var idx; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( false ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( true, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index c081a75..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = [ true ]; - for ( i = 1; i < len; i++ ) { - arr.push( false ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( true ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an 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:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 2290108..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - 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:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 1d18f3a..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( invert ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function invert( v ) { - return !v; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 8c194e1..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var identity = require( '@stdlib/utils-identity-function' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 7514266..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:of:len=5', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.of.apply( BooleanArray, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 4d6ab4e..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index e8d2c0e..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,120 +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 bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.reduce( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an 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:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 1cff5f0..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index ac6a7bb..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,120 +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 bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.reduceRight( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an 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:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index 2e76d3a..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 7d9d2a4..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 43f2780..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Uint8Array = require( '@stdlib/array-uint8' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::boolean:set', pkg ), function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i%2 ); - } - arr = new BooleanArray( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i%2 ); - } - arr = new BooleanArray( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Uint8Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i % 2; - } - arr = new BooleanArray( values ); - buf = new Uint8Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 0650925..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - var i; - - arr1 = []; - arr2 = []; - arr3 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( i > (len/2) ); - arr2.push( randu() > 0.5 ); - arr3.push( randu() < 0.2 ); - } - arr1 = new BooleanArray( arr1 ); - - values = [ - new BooleanArray( arr2 ), - new BooleanArray( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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 = 4; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index dd5928e..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index b016a0f..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench-harness' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index a237576..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v === true; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index 04670b9..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 1; i < len; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr.push( Boolean( 1 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index 58771a9..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 450d393..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 3139e8e..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 08bd8cc..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index a6aa620..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index c7237e0..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - 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 = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index c987692..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index efe6f7e..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index 5d2ee7e..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index e6b22dd..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 5d07525..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 2580a16..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Boolean = require( '@stdlib/boolean-ctor' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - 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 = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 2a4ed7f..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new BooleanArray( [ true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index aa194b4..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 9b8ade2..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - true, - false - ]; - arr = new BooleanArray( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index 22bd801..0000000 --- a/benchmark/benchmark.with.length.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new BooleanArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - 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:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0595000..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/bool" -%% click B href "https://github.com/stdlib-js/array-bool/tree/main" -%% click C href "https://github.com/stdlib-js/array-bool/tree/production" -%% click D href "https://github.com/stdlib-js/array-bool/tree/esm" -%% click E href "https://github.com/stdlib-js/array-bool/tree/deno" -%% click F href "https://github.com/stdlib-js/array-bool/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool -[production-url]: https://github.com/stdlib-js/array-bool/tree/production -[deno-url]: https://github.com/stdlib-js/array-bool/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-bool/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-bool/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-bool/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-bool/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-bool/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 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index fd93057..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var d=function(o,r){return function(){try{return r||o((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}}};var F=d(function(tr,B){"use strict";var G=require("@stdlib/boolean-ctor");function C(o){var r,t;for(r=[];t=o.next(),!t.done;)r.push(G(t.value));return r}B.exports=C});var A=d(function(er,L){"use strict";var H=require("@stdlib/boolean-ctor");function U(o,r,t){var i,e,n;for(i=[],n=-1;e=o.next(),!e.done;)n+=1,i.push(H(r.call(t,e.value,n)));return i}L.exports=U});var R=d(function(ir,O){"use strict";var z=require("@stdlib/boolean-ctor");function D(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(f("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*E));t=new c(t,o,i)}}return s(this,"_buffer",t),s(this,"_length",t.length),this}s(u,"BYTES_PER_ELEMENT",E);s(u,"name","BooleanArray");s(u,"from",function(r){var t,i,e,n,a,l,g,p,w;if(!y(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!P(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(i=arguments.length,i>1){if(e=arguments[1],!y(e))throw new TypeError(f("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(p=r.length,r.get&&r.set?g=Z("default"):g=Q("default"),n=new this(p),a=n._buffer,w=0;w=i))return v(t[r])});V(u.prototype,"buffer",function(){return this._buffer.buffer});V(u.prototype,"byteLength",function(){return this._buffer.byteLength});V(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});s(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);s(u.prototype,"copyWithin",function(r,t){if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});s(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},s(t,"next",l),s(t,"return",g),m&&s(t,m,p),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,v(e[a])],done:!1}}function g(w){return n=!0,arguments.length?{value:w,done:!0}:{done:!0}}function p(){return r.entries()}});s(u.prototype,"every",function(r,t){var i,e;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!y(r))throw new TypeError(f("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!b(t))throw new TypeError(f("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!b(i))throw new TypeError(f("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(r?a=1:a=0,l=t;l=0;n--)if(e=v(i[n]),r.call(t,e,n,this))return e});s(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!y(r))throw new TypeError(f("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=v(i[n]),r.call(t,e,n,this))return n;return-1});s(u.prototype,"forEach",function(r,t){var i,e;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!y(r))throw new TypeError(f("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return v(this._buffer[r])});s(u.prototype,"includes",function(r,t){var i,e;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!_(r))throw new TypeError(f("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!b(t))throw new TypeError(f("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,e=t;e1){if(!b(t))throw new TypeError(f("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,e=t;e0){if(!j(r))throw new TypeError(f("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(p){return e=!0,arguments.length?{value:p,done:!0}:{done:!0}}function g(){return r.keys()}});s(u.prototype,"lastIndexOf",function(r,t){var i,e;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!_(r))throw new TypeError(f("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!b(t))throw new TypeError(f("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,e=t;e>=0;e--)if(r===v(i[e]))return e;return-1});V(u.prototype,"length",function(){return this._length});s(u.prototype,"map",function(r,t){var i,e,n,a;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!y(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=v(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=v(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,v(i[a]),a,this);return n});s(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,i=this._length,e=X(i/2),n=0;n1){if(i=arguments[1],!T(i))throw new TypeError(f("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(S(r)){if(a=r.length,i+a>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(h(r)?t=r._buffer:t=r,g=e.byteOffset+i*E,t.buffer===e.buffer&&t.byteOffsetg){for(n=new c(t.length),l=0;l=this._length)throw new RangeError(f("invalid argument. Index argument is out-of-bounds. Value: `%u`.",i));e[i]=r?1:0});s(u.prototype,"slice",function(r,t){var i,e,n,a,l,g;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(a=this._buffer,l=this._length,arguments.length===0)r=0,t=l;else{if(!b(r))throw new TypeError(f("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=l,r<0&&(r=0)),arguments.length===1)t=l;else{if(!b(t))throw new TypeError(f("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=l,t<0&&(t=0)):t>l&&(t=l)}}for(rn&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*E):(n=t-r,i=e.byteOffset+r*E),new this.constructor(e.buffer,i,n<0?0:n)});s(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(arguments.length===0)e=[];else if(j(r)||J(r))e=r;else throw new TypeError(f("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(q(t))i=t;else throw new TypeError(f("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:v(n[a]),done:!1}}function g(w){return e=!0,arguments.length?{value:w,done:!0}:{done:!0}}function p(){return t.values()}});s(u.prototype,"with",function(r,t){var i,e,n;if(!h(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!b(r))throw new TypeError(f("invalid argument. First argument must be an integer. Value: `%s`.",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(f("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!_(t))throw new TypeError(f("invalid argument. Second argument must be a boolean. Value: `%s`.",t));return e=new this.constructor(this._buffer),i=e._buffer,t?i[r]=1:i[r]=0,e});Y.exports=u});var x=W();module.exports=x; -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 7a970c3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/from_iterator.js", "../lib/from_iterator_map.js", "../lib/from_array.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\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// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\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// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\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// MODULES //\n\nvar Boolean = require( '@stdlib/boolean-ctor' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar format = require( '@stdlib/string-format' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\nvar fromArray = require( './from_array.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = BooleanArray;\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* Boolean array.\n*\n* @module @stdlib/array-bool\n*\n* @example\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\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,GAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,sBAAuB,EAY9C,SAASC,EAAcC,EAAK,CAC3B,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIF,EAAG,KAAK,EACP,CAAAE,EAAE,MAGPD,EAAI,KAAMH,EAASI,E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AAUG,CAAI,EAE5BtC,GACJC,EAAakC,EAAMnC,EAAiBuC,CAAQ,EAEtCJ,EAQP,SAASE,GAAO,CAEf,OADAR,GAAK,EACAO,GAAOP,GAAKR,EACT,CACN,KAAQ,EACT,EAEM,CACN,MAASjB,EAASgB,EAAKS,CAAE,CAAE,EAC3B,KAAQ,EACT,CACD,CASA,SAASS,EAAKvB,EAAQ,CAErB,OADAqB,EAAM,GACD,UAAU,OACP,CACN,MAASrB,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAASwB,GAAU,CAClB,OAAOL,EAAK,OAAO,CACpB,CACD,CAAC,EA6BDjC,EAAagB,EAAa,UAAW,OAAQ,SAAmBgD,EAAOlD,EAAQ,CAC9E,IAAIK,EACAM,EACAL,EAEJ,GAAK,CAACP,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,oDAAqD,EAE3E,GAAK,CAAClB,EAAWqE,CAAM,EACtB,MAAM,IAAI,UAAWzD,EAAQ,oEAAqEyD,CAAM,CAAE,EAM3G,GAJA5C,EAAM,KAAK,QACN4C,EAAQ,IACZA,GAAS5C,GAEL4C,EAAQ,GAAKA,GAAS5C,EAC1B,MAAM,IAAI,WAAYb,EAAQ,kEAAmEyD,CAAM,CAAE,EAE1G,GAAK,CAACtE,EAAWoB,CAAM,EACtB,MAAM,IAAI,UAAWP,EAAQ,oEAAqEO,CAAM,CAAE,EAE3G,OAAAW,EAAM,IAAI,KAAK,YAAa,KAAK,OAAQ,EACzCN,EAAMM,EAAI,QACLX,EACJK,EAAK6C,CAAM,EAAI,EAEf7C,EAAK6C,CAAM,EAAI,EAETvC,CACR,CAAC,EAKDrC,EAAO,QAAU4B,ICn2EjB,IAAIiD,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "Boolean", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "Boolean", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_from_array", "__commonJSMin", "exports", "module", "Boolean", "fromArray", "buf", "arr", "len", "require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "isBoolean", "isInteger", "isString", "isStringArray", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "setReadOnlyAccessor", "Uint8Array", "Boolean", "getter", "floor", "accessorGetter", "format", "fromIterator", "fromIteratorMap", "fromArray", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isBooleanArray", "value", "isBooleanArrayConstructor", "BooleanArray", "byteOffset", "nargs", "buf", "len", "arg", "src", "thisArg", "clbk", "out", "tmp", "get", "i", "args", "idx", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "val", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "begin", "outlen", "compareFcn", "compare", "a", "b", "offset", "locales", "options", "opts", "loc", "index", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 8bedabb..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1266 +0,0 @@ - -{{alias}}() - A Boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a boolean array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}( booleanarray ) - Creates a boolean array from another boolean array. - - Parameters - ---------- - booleanarray: BooleanArray - Boolean array from which to generate another boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ true, false, false, true ] ) - - > var arr2 = new {{alias}}( arr1 ) - - > var len = arr2.length - 4 - - -{{alias}}( typedarray ) - Creates a boolean array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/uint8}}( [ 1, 0, 0, 1 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 4 - - -{{alias}}( obj ) - Creates a boolean array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ true, false, false, true ] ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( [ {}, null, '', 4 ] ); - > len = arr2.length - 4 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a boolean array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 240 - > var arr2 = new {{alias}}( buf, 8 ) - - > len = arr2.length - 232 - > var arr3 = new {{alias}}( buf, 8, 20 ) - - > len = arr3.length - 20 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new boolean array from an array-like object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > function map( v ) { return !v }; - > var src = [ true, false ]; - > var arr = {{alias}}.from( src, map ) - - > var len = arr.length - 2 - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - true - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new boolean array from a variable number of arguments. - - Parameters - ---------- - element0: bool - Array element. - - element1: bool (optional) - Array element. - - elementN: ...bool (optional) - Array elements. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( true, false, false, true ) - - > var len = arr.length - 4 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 1 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'BooleanArray' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Size of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying - ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > arr = new {{alias}}( buf, 64 ) - - > offset = arr.byteOffset - 64 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.BYTES_PER_ELEMENT - 1 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for noth nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: boolean|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > var v = arr.at( 1 ) - false - > v = arr.at( -1 ) - true - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > arr.copyWithin( 0, 2 ) - - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - true - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, true ] - > v = it.next().value - [ 1, false ] - > v = it.next().value - [ 2, true ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, true, true ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: boolean - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( true ); - > var v = arr.get( 0 ) - true - > v = arr.get( 1 ) - true - > v = arr.get( 2 ) - true - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: BooleanArray - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v === true ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out.get( 0 ) - true - > v = out.get( 1 ) - true - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var v = arr.find( predicate ) - true - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var idx = arr.findIndex( predicate ) - 0 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var v = arr.findLast( predicate ) - true - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > arr.forEach( clbk ); - > str - '%true%false%false%true%' - - -{{alias}}.prototype.get( i ) - Returns an array element located at integer position (index) `i`. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.set( true, 0 ); - > var v = arr.get( 0 ) - true - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, true, true ] ) - - > var bool = arr.includes( true ) - true - > bool = arr.includes( false, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, true, true ] ) - - > var idx = arr.indexOf( true ) - 0 - > idx = arr.indexOf( false, 3 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.join() - 'true,false,true' - > str = arr.join( '|' ) - 'true|false|true' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ true, false ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ true, true, true, false, true ] ) - - > var idx = arr.lastIndexOf( false ) - 3 - > idx = arr.lastIndexOf( false, 2 ) - -1 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: BooleanArray - A new typed array. - - Examples - -------- - > function invert( v ) { return !v; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.map( invert ) - - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - > v = out.get( 2 ) - false - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > function reducer( acc, v ) { return ( acc && v ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.reduce( reducer ) - false - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > function reducer( acc, v ) { return ( acc && v ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.reduceRight( reducer ) - false - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false ] ) - - > arr.reverse(); - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - false - > v = arr.get( 2 ) - true - - -{{alias}}.prototype.set( v[, i] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an index argument `i`. - - To set one or more array elements, provide an array-like object containing - truthy and falsy values. - - Parameters - ---------- - v: bool|BooleanArray|ArrayLikeObject - Boolean value or Boolean value array. - - i: integer (optional) - Array index at which to start setting elements. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > arr.set( false ); - > var v = arr.get( 0 ) - false - > arr.set( true, 1 ); - > v = arr.get( 1 ) - true - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, false, true ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 4 - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ false, true, false ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first boolean value for comparison. - - b: second boolean value for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > function compare( a, b ) { return a === true ? -1 : 1; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > arr.sort( compare ); - > var v = arr.get( 0 ) - true - > v = arr.get( 1 ) - true - > v = arr.get( 2 ) - false - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, false, true ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.toLocaleString() - 'true,false,true' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false ] ) - - > var out = arr.toReversed() - - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - false - > v = out.get( 2 ) - true - - -{{alias}}.prototype.toSorted( [compareFunction] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first boolean value for comparison. - - b: second boolean value for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > function compare( a, b ) { return a === true ? -1 : 1; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.toSorted( compare ); - > var v = out.get( 0 ) - true - > v = out.get( 1 ) - true - > v = out.get( 2 ) - false - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - out: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.toString() - 'true,false,true' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ true, false ] ) - - > var it = arr.values(); - > var v = it.next().value - true - > v = it.next().value - false - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: boolean - Element value. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.with( 0, false ) - - > var v = out.get( 0 ) - false - - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a05807a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,146 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import BooleanArray = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: boolean ): boolean { - return v; -} - - -// TESTS // - -// The function returns a boolean array... -{ - new BooleanArray(); // $ExpectType BooleanArray - BooleanArray(); // $ExpectType BooleanArray - new BooleanArray( 2 ); // $ExpectType BooleanArray - BooleanArray( 2 ); // $ExpectType BooleanArray - new BooleanArray( [ 1.0, -1.0 ] ); // $ExpectType BooleanArray - BooleanArray( [ 1.0, -1.0 ] ); // $ExpectType BooleanArray - - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf ); // $ExpectType BooleanArray - BooleanArray( buf ); // $ExpectType BooleanArray - new BooleanArray( buf, 8 ); // $ExpectType BooleanArray - BooleanArray( buf, 8 ); // $ExpectType BooleanArray - new BooleanArray( buf, 8, 2 ); // $ExpectType BooleanArray - BooleanArray( buf, 8, 2 ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new BooleanArray( true ); // $ExpectError - new BooleanArray( false ); // $ExpectError - new BooleanArray( null ); // $ExpectError - new BooleanArray( {} ); // $ExpectError - new BooleanArray( ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( true ); // $ExpectError - BooleanArray( false ); // $ExpectError - BooleanArray( null ); // $ExpectError - BooleanArray( {} ); // $ExpectError - BooleanArray( ( x: boolean ): boolean => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf, true ); // $ExpectError - new BooleanArray( buf, false ); // $ExpectError - new BooleanArray( buf, null ); // $ExpectError - new BooleanArray( buf, 'abc' ); // $ExpectError - new BooleanArray( buf, {} ); // $ExpectError - new BooleanArray( buf, ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( buf, true ); // $ExpectError - BooleanArray( buf, false ); // $ExpectError - BooleanArray( buf, null ); // $ExpectError - BooleanArray( buf, 'abc' ); // $ExpectError - BooleanArray( buf, {} ); // $ExpectError - BooleanArray( buf, ( x: boolean ): boolean => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf, 8, true ); // $ExpectError - new BooleanArray( buf, 8, false ); // $ExpectError - new BooleanArray( buf, 8, null ); // $ExpectError - new BooleanArray( buf, 8, 'abc' ); // $ExpectError - new BooleanArray( buf, 8, {} ); // $ExpectError - new BooleanArray( buf, 8, ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( buf, 8, true ); // $ExpectError - BooleanArray( buf, 8, false ); // $ExpectError - BooleanArray( buf, 8, null ); // $ExpectError - BooleanArray( buf, 8, 'abc' ); // $ExpectError - BooleanArray( buf, 8, {} ); // $ExpectError - BooleanArray( buf, 8, ( x: boolean ): boolean => x ); // $ExpectError -} - -// The `from` method returns a boolean array... -{ - BooleanArray.from( [ true, true ] ); // $ExpectType BooleanArray - BooleanArray.from( [ true, true ], ( x: boolean ): boolean => x ); // $ExpectType BooleanArray - BooleanArray.from( [ true ], clbk, {} ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - BooleanArray.from( true ); // $ExpectError - BooleanArray.from( false ); // $ExpectError - BooleanArray.from( 123 ); // $ExpectError - BooleanArray.from( null ); // $ExpectError - BooleanArray.from( {} ); // $ExpectError - - BooleanArray.from( true, clbk ); // $ExpectError - BooleanArray.from( false, clbk ); // $ExpectError - BooleanArray.from( 123, clbk ); // $ExpectError - BooleanArray.from( null, clbk ); // $ExpectError - BooleanArray.from( {}, clbk ); // $ExpectError - - BooleanArray.from( true, clbk, {} ); // $ExpectError - BooleanArray.from( false, clbk, {} ); // $ExpectError - BooleanArray.from( 123, clbk, {} ); // $ExpectError - BooleanArray.from( null, clbk, {} ); // $ExpectError - BooleanArray.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - BooleanArray.from( [ true, true ], true ); // $ExpectError - BooleanArray.from( [ true, true ], false ); // $ExpectError - BooleanArray.from( [ true, true ], 123 ); // $ExpectError - BooleanArray.from( [ true, true ], null ); // $ExpectError - BooleanArray.from( [ true, true ], {} ); // $ExpectError -} - -// The `of` method returns a boolean array... -{ - BooleanArray.of( true, true, true, true ); // $ExpectType BooleanArray -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index d1b9dcf..0000000 --- a/examples/index.js +++ /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. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var logEach = require( '@stdlib/console-log-each' ); -var BooleanArray = require( './../lib' ); - -// Create a boolean array by specifying a length: -var out = new BooleanArray( 3 ); -logEach( '%s', out ); - -// Create a boolean array from an array of booleans: -var arr = [ true, false, true ]; -out = new BooleanArray( arr ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer view: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer, 1, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 3acd0a2..368d0d1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike, BooleanArray as BooleanArrayInterface } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3a4b90f --- /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{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as o}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.3-esm/index.mjs";import{isPrimitive as s}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import{primitives as a}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.3-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function g(r){var t,e;for(t=[];!(e=r.next()).done;)t.push(y(e.value));return t}var E=w.BYTES_PER_ELEMENT,m=f();function _(r){return"object"==typeof r&&null!==r&&"BooleanArray"===r.constructor.name&&r.BYTES_PER_ELEMENT===E}function T(r){return r===j}function j(){var o,s,h,a,f;if(s=arguments.length,!(this instanceof j))return 0===s?new j:1===s?new j(arguments[0]):2===s?new j(arguments[0],arguments[1]):new j(arguments[0],arguments[1],arguments[2]);if(0===s)h=new w(0);else if(1===s)if(r(f=arguments[0]))h=new w(f);else if(t(f))h=function(r,t){var e,n;for(e=t.length,n=0;nh.byteLength-o)throw new RangeError(b("null2G",a*E));h=new w(h,o,a)}}return u(this,"_buffer",h),u(this,"_length",h.length),this}u(j,"BYTES_PER_ELEMENT",E),u(j,"name","BooleanArray"),u(j,"from",(function(r){var e,o,s,h,a,f,u,p,w;if(!i(this))throw new TypeError(b("null01"));if(!T(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if((o=arguments.length)>1){if(!i(s=arguments[1]))throw new TypeError(b("null2H",s));o>2&&(e=arguments[2])}if(t(r)){if(s){for(p=r.length,u=r.get&&r.set?d("default"):c("default"),a=(h=new this(p))._buffer,w=0;w=e))return y(t[r])})),p(j.prototype,"buffer",(function(){return this._buffer.buffer})),p(j.prototype,"byteLength",(function(){return this._buffer.byteLength})),p(j.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),u(j.prototype,"BYTES_PER_ELEMENT",j.BYTES_PER_ELEMENT),u(j.prototype,"copyWithin",(function(r,t){if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return 2===arguments.length?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this})),u(j.prototype,"entries",(function(){var r,t,e,n,i,o;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,n=this._buffer,e=this._length,o=-1,u(t={},"next",(function(){if(o+=1,i||o>=e)return{done:!0};return{value:[o,y(n[o])],done:!1}})),u(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),l&&u(t,l,(function(){return r.entries()})),t})),u(j.prototype,"every",(function(r,t){var e,n;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!i(r))throw new TypeError(b("null3c",r));for(e=this._buffer,n=0;n1){if(!s(t))throw new TypeError(b("null7f",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!s(e))throw new TypeError(b("null2z",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(h=r?1:0,a=t;a=0;o--)if(n=y(e[o]),r.call(t,n,o,this))return n})),u(j.prototype,"findLastIndex",(function(r,t){var e,n,o;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!i(r))throw new TypeError(b("null3c",r));for(e=this._buffer,o=this._length-1;o>=0;o--)if(n=y(e[o]),r.call(t,n,o,this))return o;return-1})),u(j.prototype,"forEach",(function(r,t){var e,n;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!i(r))throw new TypeError(b("null3c",r));for(e=this._buffer,n=0;n=this._length))return y(this._buffer[t])})),u(j.prototype,"includes",(function(r,t){var e,n;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!o(r))throw new TypeError(b("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!s(t))throw new TypeError(b("null7f",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n1){if(!s(t))throw new TypeError(b("null7f",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n0){if(!h(r))throw new TypeError(b("null3F",r))}else r=",";for(t=this._buffer,e=[],n=0;n=e)return{done:!0};return{value:i,done:!1}})),u(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),l&&u(t,l,(function(){return r.keys()})),t})),u(j.prototype,"lastIndexOf",(function(r,t){var e,n;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!o(r))throw new TypeError(b("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!s(t))throw new TypeError(b("null7f",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(e=this._buffer,n=t;n>=0;n--)if(r===y(e[n]))return n;return-1})),p(j.prototype,"length",(function(){return this._length})),u(j.prototype,"map",(function(r,t){var e,n,o,s;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!i(r))throw new TypeError(b("null3c"),r);for(o=this._buffer,e=(n=new this.constructor(this._length))._buffer,s=0;s1)o=t,s=0;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");o=y(e[0]),s=1}for(;s1)o=t,s=n-1;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");o=y(e[n-1]),s=n-2}for(;s>=0;s--)o=r(o,y(e[s]),s,this);return o})),u(j.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,e=this._length,n=v(e/2),i=0;i1){if(!r(i=arguments[1]))throw new TypeError(b("null2L",i))}else i=0;if(t(e)){if(i+(h=e.length)>this._length)throw new RangeError(b("null03"));if(n=_(e)?e._buffer:e,f=o.byteOffset+i*E,n.buffer===o.buffer&&n.byteOffsetf){for(s=new w(n.length),a=0;a=this._length)throw new RangeError(b("null2M",i));o[i]=e?1:0}})),u(j.prototype,"slice",(function(r,t){var e,n,i,o,h,a;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(o=this._buffer,h=this._length,0===arguments.length)r=0,t=h;else{if(!s(r))throw new TypeError(b("null7e",r));if(r<0&&(r+=h)<0&&(r=0),1===arguments.length)t=h;else{if(!s(t))throw new TypeError(b("null7f",t));t<0?(t+=h)<0&&(t=0):t>h&&(t=h)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*E):(i=t-r,e=n.byteOffset+r*E),new this.constructor(n.buffer,e,i<0?0:i)})),u(j.prototype,"toLocaleString",(function(r,t){var e,i,o,s,f;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(0===arguments.length)i=[];else{if(!h(r)&&!a(r))throw new TypeError(b("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));i=r}if(arguments.length<2)e={};else{if(!n(t))throw new TypeError(b("null2V",t));e=t}for(s=this._buffer,o=[],f=0;f=e)return{done:!0};return{value:y(i[o]),done:!1}})),u(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),l&&u(r,l,(function(){return t.values()})),r})),u(j.prototype,"with",(function(r,t){var e,n;if(!_(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!s(r))throw new TypeError(b("null7e",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(b("nullFP",r));if(!o(t))throw new TypeError(b("null55",t));return(e=new this.constructor(this._buffer))._buffer[r]=t?1:0,e}));export{j as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1f84ce6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/from_iterator.js","../lib/main.js","../lib/from_array.js","../lib/from_iterator_map.js"],"sourcesContent":["/**\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// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\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/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isObject from '@stdlib/assert-is-object';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport Uint8Array from '@stdlib/array-uint8';\nimport Boolean from '@stdlib/boolean-ctor';\nimport getter from '@stdlib/array-base-getter';\nimport floor from '@stdlib/math-base-special-floor';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( format('null03') );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'null2M', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'null55', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default BooleanArray;\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// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\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// MODULES //\n\nimport Boolean from '@stdlib/boolean-ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n"],"names":["fromIterator","it","out","v","next","done","push","Boolean","value","BYTES_PER_ELEMENT","Uint8Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isBooleanArray","constructor","name","isBooleanArrayConstructor","BooleanArray","byteOffset","nargs","buf","len","arg","arguments","length","this","isNonNegativeInteger","isCollection","arr","i","fromArray","isArrayBuffer","isObject","TypeError","format","isFunction","ITERATOR_SYMBOL","byteLength","RangeError","setReadOnly","src","thisArg","clbk","tmp","get","set","accessorGetter","getter","_buffer","call","fromIteratorMap","args","prototype","idx","isInteger","_length","setReadOnlyAccessor","buffer","target","start","copyWithin","self","iter","FLG","entries","predicate","end","val","isBoolean","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","Error","N","j","floor","sbuf","begin","outlen","compareFcn","sort","a","b","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index"],"mappings":";;q4DAkCA,SAASA,EAAcC,GACtB,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAELC,EAAIF,EAAGG,QACAC,MAGPH,EAAII,KAAMC,EAASJ,EAAEK,QAEtB,OAAON,CACR,CC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AiE,IAMA,GAJA9E,EAAAI,KAAA8B,QACA4C,EAAA,IACAA,GAAA9E,GAEA8E,EAAA,GAAAA,GAAA9E,EACA,MAAA,IAAAiB,WAAAJ,EAAA,SAAAiE,IAEA,IAAA/B,EAAA5D,GACA,MAAA,IAAAyB,UAAAC,EAAA,SAAA1B,IASA,OAPAN,EAAA,IAAAuB,KAAAX,YAAAW,KAAAuB,UACAA,QAEAmD,GADA3F,EACA,EAEA,EAEAN,CACA"} \ No newline at end of file diff --git a/lib/from_array.js b/lib/from_array.js deleted file mode 100644 index 350a5a3..0000000 --- a/lib/from_array.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Fills an output array with "boolean" values. -* -* @private -* @param {Uint8Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint8Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = Boolean( arr[ i ] ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index 1777c12..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( Boolean( v.value ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 3f564d2..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( Boolean( clbk.call( thisArg, v.value, i ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0ded24d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Boolean array. -* -* @module @stdlib/array-bool -* -* @example -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var arr = new BooleanArray(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var arr = new BooleanArray( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var arr = new BooleanArray( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf ); -* // returns -* -* var len = arr.length; -* // returns 16 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var BooleanArray = require( '@stdlib/array-bool' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new BooleanArray( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// 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 6448a45..0000000 --- a/lib/main.js +++ /dev/null @@ -1,2492 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var getter = require( '@stdlib/array-base-getter' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var format = require( '@stdlib/string-format' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); -var fromArray = require( './from_array.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `BooleanArray`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `BooleanArray` -*/ -function isBooleanArray( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'BooleanArray' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a boolean typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a boolean typed array constructor -*/ -function isBooleanArrayConstructor( value ) { - return ( value === BooleanArray ); -} - - -// MAIN // - -/** -* Boolean array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {BooleanArray} boolean array -* -* @example -* var arr = new BooleanArray(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new BooleanArray( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new BooleanArray( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf ); -* // returns -* -* var len = arr.length; -* // returns 16 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new BooleanArray( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function BooleanArray() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - - nargs = arguments.length; - if ( !(this instanceof BooleanArray) ) { - if ( nargs === 0 ) { - return new BooleanArray(); - } - if ( nargs === 1 ) { - return new BooleanArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new BooleanArray( arguments[0], arguments[1] ); - } - return new BooleanArray( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint8Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint8Array( arg ); - } else if ( isCollection( arg ) ) { - buf = fromArray( new Uint8Array( arg.length ), arg ); - } else if ( isArrayBuffer( arg ) ) { - buf = new Uint8Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = new Uint8Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( nargs === 2 ) { - buf = new Uint8Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint8Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof BooleanArray -* @readonly -* @type {PositiveInteger} -* @default 1 -* -* @example -* var nbytes = BooleanArray.BYTES_PER_ELEMENT; -* // returns 1 -*/ -setReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof BooleanArray -* @readonly -* @type {string} -* @default 'BooleanArray' -* -* @example -* var str = BooleanArray.name; -* // returns 'BooleanArray' -*/ -setReadOnly( BooleanArray, 'name', 'BooleanArray' ); - -/** -* Creates a new boolean array from an array-like object or an iterable. -* -* @name from -* @memberof BooleanArray -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {BooleanArray} boolean array -* -* @example -* var arr = BooleanArray.from( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return !v; -* } -* -* var arr = BooleanArray.from( [ true, false ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( BooleanArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isBooleanArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); -}); - -/** -* Creates a new boolean array from a variable number of arguments. -* -* @name of -* @memberof BooleanArray -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} boolean array -* -* @example -* var arr = BooleanArray.of( true, true, true, true ); -* // returns -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( BooleanArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isBooleanArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} must provide an integer -* @returns {(boolean|void)} array element -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.at( 0 ); -* // returns true -* -* v = arr.at( -1 ); -* // returns true -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( BooleanArray.prototype, 'at', function at( idx ) { - var buf; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - len = this._length; - buf = this._buffer; - if ( idx < 0 ) { - idx += len; - } - if ( idx < 0 || idx >= len ) { - return; - } - return Boolean( buf[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof BooleanArray.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 10 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof BooleanArray.prototype -* @readonly -* @type {PositiveInteger} -* @default 1 -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 1 -*/ -setReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} modified array -* -* @example -* var arr = new BooleanArray( 4 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* arr.set( true, 3 ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr.get( 2 ); -* // returns true -* -* v = arr.get( 3 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, true ] -* -* v = it.next().value; -* // returns [ 1, false ] -* -* v = it.next().value; -* // returns [ 2, true ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, Boolean( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( true, 1 ); -* arr.set( true, 2 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {BooleanArray} modified array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.fill( true, 1 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* v = arr.get( 1 ); -* // returns true -* -* v = arr.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var val; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - if ( value ) { - val = 1; - } else { - val = 0; - } - for ( i = start; i < end; i++ ) { - buf[ i ] = val; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} boolean array -* -* @example -* function predicate( v ) { -* return ( v === true ); -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out.get( 0 ); -* // returns true -* -* v = out.get( 1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.find( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findIndex( predicate ); -* // returns 0 -*/ -setReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findLast( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* arr.forEach( log ); -*/ -setReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, Boolean( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @name get -* @memberof BooleanArray.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(boolean|void)} array element -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* arr.set( [ true, false ], 0 ); -* -* v = arr.get( 0 ); -* // returns true -* -* v = arr.get( 100 ); -* // returns undefined -*/ -setReadOnly( BooleanArray.prototype, 'get', function get( idx ) { - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return Boolean( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( true, 3 ); -* arr.set( true, 4 ); -* -* var bool = arr.includes( true ); -* // returns true -* -* bool = arr.includes( false, 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( true, 3 ); -* arr.set( true, 4 ); -* -* var idx = arr.indexOf( true ); -* // returns 0 -* -* idx = arr.indexOf( false, 2 ); -* // returns -1 -* -* idx = arr.indexOf( false, -3 ); -* // returns -1 -*/ -setReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof BooleanArray.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.join(); -* // returns 'true,false,true' -* -* str = arr.join( '|' ); -* // returns 'true|false|true' -*/ -setReadOnly( BooleanArray.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - if ( buf[i] ) { - out.push( 'true' ); - } else { - out.push( 'false' ); - } - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 2 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( true, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var idx = arr.lastIndexOf( true ); -* // returns 4 -* -* idx = arr.lastIndexOf( false, 2 ); -* // returns -1 -* -* idx = arr.lastIndexOf( false, -3 ); -* // returns -1 -*/ -setReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - for ( i = fromIndex; i >= 0; i-- ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} new boolean array -* -* @example -* function invert( v ) { -* return !v; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.map( invert ); -* // returns -* -* var z = out.get( 0 ); -* // returns false -* -* z = out.get( 1 ); -* // returns true -* -* z = out.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) ); - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a boolean array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function reducer( acc, v ) { -* if ( v ) { -* return acc + 1; -* } -* return acc; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.reduce( reducer, 0 ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = Boolean( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, Boolean( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a boolean array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function reducer( acc, v ) { -* if ( v ) { -* return acc + 1; -* } -* return acc; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.reduceRight( reducer, 0 ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = Boolean( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, Boolean( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} reversed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out.get( 0 ); -* // returns false -* -* v = out.get( 1 ); -* // returns false -* -* v = out.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - N = floor( len / 2 ); - for ( i = 0; i < N; i++ ) { - j = len - i - 1; - tmp = buf[ i ]; - buf[ i ] = buf[ j ]; - buf[ j ] = tmp; - } - return this; -}); - -/** -* Sets an array element. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof BooleanArray.prototype -* @type {Function} -* @param {(Collection|BooleanArray|*)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* arr.set( [ true, false ], 0 ); -* -* v = arr.get( 0 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var N; - var i; - var j; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - if ( isCollection( value ) ) { - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - if ( isBooleanArray( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - } else { - sbuf = value; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint8Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays - } - sbuf = tmp; - } - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = ( sbuf[ i ] ) ? 1 : 0; - } - return; - } - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - buf[ idx ] = ( value ) ? 1 : 0; -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {BooleanArray} boolean array -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var bool = out.get( 0 ); -* // returns true -* -* bool = out.get( len-1 ); -* // returns true -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* bool = out.get( 0 ); -* // returns false -* -* bool = out.get( len-1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( false, 0 ); -* arr.set( true, 1 ); -* arr.set( false, 2 ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} sorted array -* -* @example -* function compare( a, b ) { -* if ( a === false ) { -* if ( b === false ) { -* return 0; -* } -* return 1; -* } -* if ( b === true ) { -* return 0; -* } -* return -1; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* arr.sort( compare ); -* -* var v = arr.get( 0 ); -* // returns true -* -* v = arr.get( 1 ); -* // returns true -* -* v = arr.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort(); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Comparison function for sorting. - * - * @private - * @param {boolean} a - first boolean value for comparison - * @param {boolean} b - second boolean value for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( Boolean( a ), Boolean( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {BooleanArray} subarray -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr.get( 0 ); -* // returns true -* -* bool = subarr.get( len-1 ); -* // returns true -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr.get( 0 ); -* // returns false -* -* bool = subarr.get( len-1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof BooleanArray.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.toLocaleString(); -* // returns 'true,false,true' -*/ -setReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) ); - } - return out.join( ',' ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} reversed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out.get( 0 ); -* // returns false -* -* v = out.get( 1 ); -* // returns false -* -* v = out.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - outbuf[ i ] = buf[ len - i - 1 ]; - } - return out; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} sorted array -* -* @example -* function compare( a, b ) { -* if ( a === false ) { -* if ( b === false ) { -* return 0; -* } -* return 1; -* } -* if ( b === true ) { -* return 0; -* } -* return -1; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var v = out.get( 0 ); -* // returns true -* -* v = out.get( 1 ); -* // returns true -* -* v = out.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - outbuf[ i ] = buf[ i ]; - } - if ( arguments.length === 0 ) { - outbuf.sort(); - return out; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - outbuf.sort( compare ); - return out; - - /** - * Comparison function for sorting. - * - * @private - * @param {boolean} a - first boolean value for comparison - * @param {boolean} b - second boolean value for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( Boolean( a ), Boolean( b ) ); - } -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.toString(); -* // returns 'true,false,true' -*/ -setReadOnly( BooleanArray.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( buf[i] ) { - out.push( 'true' ); - } else { - out.push( 'false' ); - } - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 2 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns true -* -* v = iter.next().value; -* // returns false -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': Boolean( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} index - element index -* @param {boolean} value - new value -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a boolean -* @returns {BooleanArray} new typed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.with( 0, false ); -* // returns -* -* var v = out.get( 0 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) { - var buf; - var out; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); - } - if ( !isBoolean( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) ); - } - out = new this.constructor( this._buffer ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - if ( value ) { - buf[ index ] = 1; - } else { - buf[ index ] = 0; - } - return out; -}); - - -// EXPORTS // - -module.exports = BooleanArray; diff --git a/package.json b/package.json index 44b73ef..0b695ea 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.2", "description": "BooleanArray.", "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,62 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.3", - "@stdlib/array-base-getter": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/boolean-ctor": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/string-format": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-base-randu": "^0.2.3", - "@stdlib/strided-base-reinterpret-boolean": "^0.0.3", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..26abf7d --- /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.at.js b/test/test.at.js deleted file mode 100644 index f1ed54e..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,136 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var expected; - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = [ true, false, true, false, true, true, false, true, false, true ]; - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - t.strictEqual( v, expected[ i+arr.length ], 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index 16d4894..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,215 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a boolean array', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, 5 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( -arr.length, 5 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, -3 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, 5, arr.length ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0, 4 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0, -4 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( arr.length, 5 ); - - expected = new Uint8Array( [ 1, 0, 0, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 1, 0 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 8ea46ec..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isBoolean( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], buf[ i ], 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 0 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 0 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': false - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0bb8a18..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, true, true, true ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, true, true ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index 6e40f6a..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,280 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( true, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.fill( true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.fill( true ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr.fill( true ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 1, 1 ] ); - - arr.fill( true, 1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 0 ] ); - - arr.fill( true, 0, 2 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 0 ] ); - - arr.fill( true, -3, -1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr.fill( true, -10 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 1, 1 ] ); - - arr.fill( true, 1, 10 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 0, 0 ] ); - - arr.fill( true, 2, 1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 4294e79..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,208 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns a new boolean array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true ] ); - expected = new Uint8Array( [ 1, 1 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, true, true, true ] ); - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - expected = new Uint8Array( [] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new BooleanArray( [ true, false, true ] ); - expected = new Uint8Array( [ 1, 1 ] ); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 809593a..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty boolean array', function test( t ) { - var arr; - var v; - - arr = new BooleanArray(); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, false, true, false ] ); - v = arr.find( predicate ); - - t.strictEqual( v, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, true, true, true, true ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, false, true, false ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, false, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === false ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index 975c0db..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, true, true ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, false, false ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 53da06b..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty boolean array', function test( t ) { - var arr; - var v; - - arr = new BooleanArray(); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, true, true, true, true ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, false, true, false ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index f0acaf4..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, true, true ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, false, false ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index 5824863..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isBoolean( v ) ) { - t.fail( 'should be a boolean' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray(); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isBoolean( v ) ) { - t.fail( 'should be a boolean' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new BooleanArray( [ true, false, false, true ] ); - arr.forEach( fcn ); - - t.deepEqual( values, [ true, false, false, true ], 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, false, false, true ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index dc3c118..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a boolean array from an array-like object or iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.from ), true, 'has method' ); - - arr = BooleanArray.from( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value, clbk ); - }; - } - - function clbk() { - return true; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value, clbk, {} ); - }; - } - - function clbk() { - return true; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a boolean array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = BooleanArray.from( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( [ true, true, true, true ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-booleans: - arr = BooleanArray.from( [ 'beep' ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ null, 4 ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = BooleanArray.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = BooleanArray.from( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new Uint8Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = BooleanArray.from( new BooleanArray( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new BooleanArray( [ true, false ] ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a boolean array (iterable)', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = BooleanArray.from( createIterable( iter ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = BooleanArray.from( [], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( [ true, true, true, true ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-booleans: - arr = BooleanArray.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = BooleanArray.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = BooleanArray.from( new Uint8Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new Uint8Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = BooleanArray.from( new BooleanArray( 0 ), clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new BooleanArray( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = BooleanArray.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = BooleanArray.from( [ true, true, true, true ], clbk1, ctx ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var BooleanArray; - var iter; - var ctx; - var arr; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = BooleanArray.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index fe45a39..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, Boolean( i%2 ), 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index 09d682a..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,221 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.includes( true ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a boolean value is not found', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( 10 ); - bool = arr.includes( true ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified boolean value', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, false, true] ); - bool = arr.includes( false ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( 10 ); - bool = arr.includes( true, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 0360771..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,221 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.indexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a boolean value is not found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.indexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a boolean value is found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - idx = arr.indexOf( false ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.indexOf( false, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( true, 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( false, 3 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( false, -2 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( true, -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index bcc39a0..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,162 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true@false@false@true'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true ] ); - expected = 'true'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new BooleanArray( [ false ] ); - expected = 'false'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a boolean array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true,false,false,true'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6db4ae0..0000000 --- a/test/test.js +++ /dev/null @@ -1,660 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new BooleanArray( 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (no argument)', function test( t ) { - var arr = new BooleanArray(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (length)', function test( t ) { - var arr = new BooleanArray( 10 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (array)', function test( t ) { - var arr = new BooleanArray( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (typed array)', function test( t ) { - var arr = new BooleanArray( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (iterable)', function test( t ) { - var BooleanArray; - var arr; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new BooleanArray( createIterable() ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a boolean array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( BooleanArray.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray, 'name' ), true, 'has property' ); - t.strictEqual( BooleanArray.name, 'BooleanArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( BooleanArray.prototype.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - - arr = new BooleanArray( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new BooleanArray( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new BooleanArray(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new BooleanArray( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new BooleanArray( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( [ true, false, true, false ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new BooleanArray( new Uint8Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new Uint8Array( [ 1, 1 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = new BooleanArray( new BooleanArray( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new BooleanArray( [ true, true ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new BooleanArray( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new BooleanArray( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 572a8b5..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new BooleanArray( [ true, false ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new BooleanArray( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 32e0b1d..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,210 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.lastIndexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a boolean value is not found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.lastIndexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - idx = arr.lastIndexOf( false ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( false, -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index b4ed8de..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,164 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var reinterpretBool = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new boolean array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - actual = arr.map( invert ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return !v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 15, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return !v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 3a15165..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a boolean array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.of ), true, 'has method' ); - - arr = BooleanArray.of(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a boolean array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = BooleanArray.of(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Boolean arguments: - arr = BooleanArray.of( true, false, false, true ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-boolean arguments: - arr = BooleanArray.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = BooleanArray.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 4f50735..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,197 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new BooleanArray( [ true, false, true, false ] ); - accArray = [ true, false, false ]; - valueArray = [ false, true, false ]; - expected = false; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - accArray = [ 0, 1, 1, 1 ]; - valueArray = [ true, false, false, true ]; - expected = 2; - actual = arr.reduce( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, accArray[ index ], 'returns expected value' ); - t.strictEqual( value, valueArray[ index ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = false; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 43b200e..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,200 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new BooleanArray( [ true, false, true, false ] ); - len = arr.length; - accArray = [ false, false, false ]; - valueArray = [ true, false, true ]; - expected = false; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new BooleanArray( [ true, false, false, true ] ); - len = arr.length; - accArray = [ 0, 1, 1, 1 ]; - valueArray = [ true, false, false, true ]; - expected = 2; - actual = arr.reduceRight( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = false; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index ed1792e..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reverse` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reverse.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.reverse(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method reverses elements of a boolean array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - out = arr.reverse(); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 924fa3d..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,387 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (non-array)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - arr.length, - arr.length + 1, - arr.length + 2, - arr.length + 3 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new BooleanArray( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( true ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets an array element (non-array)', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - - v = arr.get( 0 ); - t.strictEqual( v, false, 'returns expected value' ); - - // No index argument: - arr.set( true ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - arr.set( false ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - - arr.set( true, i ); - v = arr.get( i ); - t.strictEqual( v, true, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method sets an array element (array-like object)', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - - v = arr.get( 0 ); - t.strictEqual( v, false, 'returns expected value' ); - - // No index argument: - arr.set( [ true ] ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - arr.set( [ false ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - - arr.set( [ true ], i ); - - v = arr.get( i ); - t.strictEqual( v, true, 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ true, true ] ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ true, true ], 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new BooleanArray( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (boolean array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new BooleanArray( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index 95b93f1..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,271 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 1, 0, 1, 0, 1 ] ); - actual = arr.slice(); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.slice( 1 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1 ] ); - actual = arr.slice( 1, 3 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.slice( 1, 30 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - - expected = new Uint8Array( [ 1, 0 ] ); - actual = arr.slice( -3, -1 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 0, 1 ] ); - actual = arr.slice( -30, -2 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - actual = arr.slice( 2, 0 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - expected = new Uint8Array( [] ); - actual = arr.slice( 5 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint8Array( [] ); - - actual = arr.slice( 2, -8 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index d8bafb8..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,195 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ false, true, false, true ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, false, true ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index 0fac28d..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,168 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a boolean array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 0, 1, 1, 1 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 8135812..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 1, 0, 1, 0, 1 ] ); - actual = arr.subarray(); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.subarray( 1 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1 ] ); - actual = arr.subarray( 1, 3 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - - expected = new Uint8Array( [ 1, 0 ] ); - actual = arr.subarray( -3, -1 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 0, 1 ] ); - actual = arr.subarray( -30, -2 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - actual = arr.subarray( 2, 0 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - expected = new Uint8Array( [] ); - actual = arr.subarray( 5 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - - actual = arr.subarray( 2, -8 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6a89d42..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, true ] ); - expected = 'true,false,true'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index 01c81b8..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toReversed` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toReversed.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.toReversed(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - out = arr.toReversed(); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 1a9556d..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,167 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 0, 0, 1, 1, 1 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index db7f927..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true,false,false,true'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 5de851a..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,263 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new BooleanArray( [ true, false ] ); - expected = [ - { - 'value': true, - 'done': false - }, - { - 'value': false, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isBoolean( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new BooleanArray( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, false, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, false, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': false - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index 62cb315..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,200 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, false ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a boolean', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.with( 5, true ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new boolean array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, false ] ); - expected = new Uint8Array( [ 1, 0, 0, 1 ] ); - out = arr.with( 3, true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false ] ); - expected = new Uint8Array( [ 1, 0, 1 ] ); - - out = arr.with( -1, true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -});