diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 63a010d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-14T03:27:14.123Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index cfcd2ce..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/uint64) 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 68a1785..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/uint64) 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 fc68cbb..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: '55 7 * * 1' - - # 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 + + ```
@@ -542,7 +533,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]. @@ -609,13 +600,13 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray -[@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 -[@stdlib/number/uint64/ctor]: https://github.com/stdlib-js/number-uint64-ctor +[@stdlib/number/uint64/ctor]: https://github.com/stdlib-js/number-uint64-ctor/tree/esm -[@stdlib/bigint/ctor]: https://github.com/stdlib-js/bigint-ctor +[@stdlib/bigint/ctor]: https://github.com/stdlib-js/bigint-ctor/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 f76335b..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint64 = require( '@stdlib/assert-is-uint64' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var u; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Uint64( i ) ); - } - arr = new Uint64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - u = arr.at( i%N ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var u; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Uint64( i ) ); - } - arr = new Uint64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - u = arr.at( -(i%N)-1 ); - if ( typeof u !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint64( u ) ) { - b.fail( 'should return a 64-bit unsigned integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index cd3e24a..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint64Array( zeroTo( 10, 'generic' ) ); - - 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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 10b02ea..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,239 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var add = require( '@stdlib/number-uint64-base-add' ); -var bench = require( '@stdlib/bench-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = 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 Uint32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint64Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint64Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return add( v, v ); - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint64Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint64Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return add( v, 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 = Uint64Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint64Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return add( v, v ); - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 6fc29cd..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint64 = require( '@stdlib/assert-is-uint64' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = zeroTo( 10, 'generic' ); - arr = new Uint64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( !isUint64( v ) ) { - b.fail( 'should return a Uint64' ); - } - } - b.toc(); - if ( !isUint64( v ) ) { - b.fail( 'should return a Uint64' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 3e0c066..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,340 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 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 Uint32Array = require( '@stdlib/array-uint32' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = 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 Uint64Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Uint64Array; - - 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 Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Uint64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - 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 Uint64Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint64Array(); - - 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 Uint64Array(); - - 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 Uint64Array(); - - 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 Uint64Array(); - - 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.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 04d2e3d..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Uint64Array = 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 = Uint64Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !(arr instanceof Uint64Array) ) { - b.fail( 'should return a Uint64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 099b57f..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Uint64Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasBigIntSupport() -}; - - -// MAIN // - -bench( format( '%s::nonnegative_integer:set', pkg ), function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = zeroTo( 10, 'generic' ); - arr = new Uint64Array( 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::bigint:set', pkg ), opts, function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( BigInt( i ) ); - } - arr = new Uint64Array( 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::Uint64:set', pkg ), function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( new Uint64( i ) ); - } - arr = new Uint64Array( 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 buf; - var arr; - var N; - var v; - var i; - - values = zeroTo( 10, 'generic' ); - N = values.length; - - arr = new Uint64Array( 2 ); - buf = [ 0 ]; - - 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(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = zeroTo( 20, 'uint32' ); - N = values.length; - - arr = new Uint64Array( 2 ); - buf = new Uint32Array( 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(); -}); - -bench( format( '%s::uint64array:set', pkg ), function benchmark( b ) { - var values; - var arr; - var v; - var i; - - values = new Uint64Array( [ 1234 ] ); - arr = new Uint64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values ); - 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/branches.md b/branches.md deleted file mode 100644 index 5c2b128..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/uint64" -%% click B href "https://github.com/stdlib-js/array-uint64/tree/main" -%% click C href "https://github.com/stdlib-js/array-uint64/tree/production" -%% click D href "https://github.com/stdlib-js/array-uint64/tree/esm" -%% click E href "https://github.com/stdlib-js/array-uint64/tree/deno" -%% click F href "https://github.com/stdlib-js/array-uint64/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/uint64 -[production-url]: https://github.com/stdlib-js/array-uint64/tree/production -[deno-url]: https://github.com/stdlib-js/array-uint64/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-uint64/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-uint64/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-uint64/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-uint64/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-uint64/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 2ffb231..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var _=function(a,r){return function(){try{return r||a((r={exports:{}}).exports,r),r.exports}catch(e){throw r=0,e}}};var B=_(function(_r,k){"use strict";var X=require("@stdlib/assert-is-little-endian"),U,I,V;X===!0?(I=1,V=0):(I=0,V=1);U={HIGH:I,LOW:V};k.exports=U});var j=_(function(qr,G){"use strict";var Z=require("@stdlib/assert-is-uint64"),$=require("@stdlib/number-uint64-base-to-words").assign,rr=require("@stdlib/number-uint64-ctor"),er=require("@stdlib/string-format");function tr(a){var r,e,t,n;for(r=[0,0],e=[];t=a.next(),!t.done;){if(n=t.value,!Z(n))try{n=new rr(n)}catch(i){return new TypeError(er("invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.",n))}$(n,r,1,0),e.push(r[0],r[1])}return e}G.exports=tr});var N=_(function(Lr,S){"use strict";var nr=require("@stdlib/assert-is-uint64"),ir=require("@stdlib/number-uint64-base-to-words").assign,ar=require("@stdlib/number-uint64-ctor"),ur=require("@stdlib/string-format");function or(a,r,e){var t,n,i,u,o;for(t=[0,0],n=[],o=-1;i=a.next(),!i.done;){if(o+=1,u=r.call(e,i.value,o),!nr(u))try{u=new ar(u)}catch(h){return new TypeError(ur("invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.",u))}ir(u,t,1,0),n.push(t[0],t[1])}return n}S.exports=or});var x=_(function(Or,Y){"use strict";var sr=require("@stdlib/assert-is-uint64"),fr=require("@stdlib/number-uint64-base-to-words").assign,gr=require("@stdlib/number-uint64-ctor"),hr=require("@stdlib/string-format"),P=B();function vr(a,r){var e,t,n,i,u;for(e=[0,0],t=r.length,u=0,i=0;ie.byteLength-a)throw new RangeError(f("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",t*b));e=new w(e,a,t*2)}}return y(this,"_buffer",e),y(this,"_length",e.length/2),this}y(g,"BYTES_PER_ELEMENT",b);y(g,"name","Uint64Array");y(g,"from",function(r){var e,t,n,i,u,o,h,s,v,m,c,q;if(!d(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!J(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if(t=arguments.length,t>1){if(i=arguments[1],!d(i))throw new TypeError(f("invalid argument. Second argument must be a function. Value: `%s`.",i));t>2&&(e=arguments[2])}if(M(r)){if(i){for(v=r.length,r.get&&r.set?s=cr("default"):s=br("default"),u=new this(v),o=u._buffer,n=[0,0],q=0,c=0;c=this._length))return W(this._buffer,r)});H(g.prototype,"buffer",function(){return this._buffer.buffer});H(g.prototype,"byteLength",function(){return this._buffer.byteLength});H(g.prototype,"byteOffset",function(){return this._buffer.byteOffset});y(g.prototype,"BYTES_PER_ELEMENT",g.BYTES_PER_ELEMENT);y(g.prototype,"entries",function(){var r,e,t,n,i,u;if(!T(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");return e=this,r=this._buffer,n=this._length,u=-1,t={},y(t,"next",o),y(t,"return",h),E&&y(t,E,s),t;function o(){return u+=1,i||u>=n?{done:!0}:{value:[u,W(r,u)],done:!1}}function h(v){return i=!0,arguments.length?{value:v,done:!0}:{done:!0}}function s(){return e.entries()}});y(g.prototype,"get",function(r){if(!T(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if(!p(r))throw new TypeError(f("invalid argument. Must provide a nonnegative integer. Value: `%s`.",r));if(!(r>=this._length))return W(this._buffer,r)});H(g.prototype,"length",function(){return this._length});y(g.prototype,"set",function(r){var e,t,n,i,u,o,h,s,v;if(!T(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if(i=this._buffer,arguments.length>1){if(n=arguments[1],!p(n))throw new TypeError(f("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",n))}else n=0;if(e=[0,0],R(r)){if(n>=this._length)throw new RangeError(f("invalid argument. Index argument is out-of-bounds. Value: `%u`.",n));n*=2,O(r,e,1,0),i[n+l.HIGH]=e[0],i[n+l.LOW]=e[1];return}if(p(r)||yr(r)&&p(wr(r))){if(n>=this._length)throw new RangeError(f("invalid argument. Index argument is out-of-bounds. Value: `%u`.",n));r=new A(r),n*=2,O(r,e,1,0),i[n+l.HIGH]=e[0],i[n+l.LOW]=e[1];return}if(T(r)){if(o=r._length,n+o>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,v=i.byteOffset+n*b,t.buffer===i.buffer&&t.byteOffsetv){for(u=new w(t.length),s=0;sthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,v=i.byteOffset+n*b,t.buffer===i.buffer&&t.byteOffsetv){for(u=new w(t.length),s=0;s\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Uint64Array( 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Uint64Array( [ 1, 2 ] );\n* // returns [ 1n, 2n ]\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( 32 );\n* var arr = new Uint64Array( buf );\n* // returns [ 0n, 0n, 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Uint64Array( buf, 16 );\n* // returns [ 0n, 0n ]\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( 64 );\n* var arr = new Uint64Array( buf, 16, 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Uint64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar tmp;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Uint64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Uint64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Uint64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Uint64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Uint64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint32Array( arg*2 );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tlen = arg.length;\n\t\t\tif ( isUint64Array( arg ) ) {\n\t\t\t\t// Source is already arranged as high/low words, so just copy buffer to buffer:\n\t\t\t\tbuf = new Uint32Array( arg._buffer ); // eslint-disable-line no-underscore-dangle\n\t\t\t} else {\n\t\t\t\t// Assume that every element represents a single 64-bit unsigned integer:\n\t\t\t\tbuf = fromArray( new Uint32Array( len*2 ), arg );\n\t\t\t\tif ( buf instanceof Error ) {\n\t\t\t\t\tthrow buf;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint32Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tbuf = 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`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ 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`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ 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`.', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tlen = buf.length;\n\t\t\ttmp = new Uint32Array( len );\n\t\t\tfor ( i = 0; i < len; i += 2 ) {\n\t\t\t\ttmp[ i+indices.HIGH ] = buf[ i ];\n\t\t\t\ttmp[ i+indices.LOW ] = buf[ i+1 ];\n\t\t\t}\n\t\t\tbuf = tmp;\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 ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint32Array( 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 Uint32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Uint64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Uint64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Uint64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Uint64Array\n* @readonly\n* @type {string}\n* @default 'Uint64Array'\n*\n* @example\n* var name = Uint64Array.name;\n* // returns 'Uint64Array'\n*/\nsetReadOnly( Uint64Array, 'name', 'Uint64Array' );\n\n/**\n* Creates a new 64-bit unsigned integer array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Uint64Array\n* @type {Function}\n* @param {(Collection|Object)} 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 64-bit unsigned integer 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* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} an iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} when provided an iterator, a callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @returns {Uint64Array} 64-bit unsigned integer array\n*\n* @example\n* var arr = Uint64Array.from( [ 1, 2, 3 ] );\n* // returns [ 1n, 2n, 3n ]\n*\n* var len = arr.length;\n* // returns 3\n*\n* @example\n* var Uint64 = require( '@stdlib/number-uint64-ctor' );\n*\n* var arr = Uint64Array.from( [ new Uint64( 1 ) ] );\n* // returns [ 1n ]\n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var Uint64 = require( '@stdlib/number-uint64-ctor' );\n* var add = require( '@stdlib/number-uint64-base-add' );\n*\n* function clbk( v ) {\n* return add( v, v );\n* }\n*\n* var arr = Uint64Array.from( [ new Uint64( 1 ) ], clbk );\n* // returns [ 2n ]\n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Uint64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar words;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isUint64ArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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\n\t\t\twords = [ 0, 0 ];\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( !isUint64( v ) ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tv = new Uint64( v );\n\t\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. A callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttoWords( v, words, 1, 0 );\n\t\t\t\tbuf[ j+indices.HIGH ] = words[ 0 ];\n\t\t\t\tbuf[ j+indices.LOW ] = words[ 1 ];\n\t\t\t\tj += 2; // stride\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\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < tmp.length; i += 2 ) {\n\t\t\tbuf[ i+indices.HIGH ] = tmp[ i ];\n\t\t\tbuf[ i+indices.LOW ] = tmp[ i+1 ];\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 64-bit unsigned integer array from a variable number of arguments.\n*\n* @name of\n* @memberof Uint64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @returns {Uint64Array} 64-bit unsigned integer array\n*\n* @example\n* var arr = Uint64Array.of( 1, 2, 3, 4 );\n* // returns [ 1n, 2n, 3n, 4n ]\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Uint64Array, '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 ( !isUint64ArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 Uint64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @throws {TypeError} must provide an integer\n* @returns {(Uint64|void)} array element\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var u = arr.at( 0 );\n* // returns [ 0n ]\n*\n* arr.set( 1, 0 );\n* arr.set( 2, 1 );\n* arr.set( 9, 9 );\n*\n* u = arr.at( 0 );\n* // returns [ 1n ]\n*\n* u = arr.at( -1 );\n* // returns [ 9n ]\n*\n* u = arr.at( 100 );\n* // returns undefined\n*\n* u = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Uint64Array.prototype, 'at', function at( idx ) {\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getUint64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Uint64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_ELEMENT );\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Uint64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @returns {Iterator} iterator\n*\n* @example\n* var Uint64 = require( '@stdlib/number-uint64-ctor' );\n*\n* var arr = [\n* new Uint64( 1 ),\n* new Uint64( 2 ),\n* new Uint64( 3 )\n* ];\n* arr = new Uint64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, [ 1n ] ]\n*\n* v = it.next().value;\n* // returns [ 1, [ 2n ] ]\n*\n* v = it.next().value;\n* // returns [ 2, [ 3n ] ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Uint64Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );\n\t}\n\tself = this;\n\tbuffer = 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, getUint64( buffer, 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* Returns an array element.\n*\n* @name get\n* @memberof Uint64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Uint64|void)} array element\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns [ 0n ]\n*\n* arr.set( [ 1 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns [ 1n ]\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Uint64Array.prototype, 'get', function get( idx ) {\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 getUint64( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Uint64Array.prototype, 'length', function get() {\n\treturn this._length;\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 Uint64Array.prototype\n* @type {Function}\n* @param {(Collection|Uint64Array|Uint64|bigint|number)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a 64-bit unsigned integer 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* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} first argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers\n* @returns {void}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns [ 0n ]\n*\n* arr.set( 1n, 0 );\n*\n* z = arr.get( 0 );\n* // returns [ 1n ]\n*/\nsetReadOnly( Uint64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar words;\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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\twords = [ 0, 0 ];\n\tif ( isUint64( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\ttoWords( value, words, 1, 0 );\n\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\treturn;\n\t}\n\tif ( isNonNegativeInteger( value ) || ( isBigInt( value ) && isNonNegativeInteger( Number( value ) ) ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tvalue = new Uint64( value );\n\t\tidx *= 2;\n\t\ttoWords( value, words, 1, 0 );\n\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\treturn;\n\t}\n\tif ( isUint64Array( 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\tsbuf = value._buffer;\n\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 Uint32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx+indices.HIGH ] = sbuf[ j+indices.HIGH ];\n\t\t\tbuf[ idx+indices.LOW ] = sbuf[ j+indices.LOW ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\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\tsbuf = value;\n\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 Uint32Array( 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\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = sbuf[ i ];\n\t\t\tif ( !isUint64( v ) ) {\n\t\t\t\ttry {\n\t\t\t\t\tv = new Uint64( v );\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. An array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoWords( v, words, 1, 0 );\n\t\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n\n// EXPORTS //\n\nmodule.exports = Uint64Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* 64-bit unsigned integer array.\n*\n* @module @stdlib/array-uint64\n*\n* @example\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var arr = new Uint64Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var arr = new Uint64Array( 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var arr = new Uint64Array( [ 1 ] );\n* // returns [ 1n ]\n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Uint64Array( buf );\n* // returns [ 0n, 0n, 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Uint64Array( buf, 16 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Uint64Array = require( '@stdlib/array-uint64' );\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = new Uint64Array( buf, 16, 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //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CAEzB,GADAO,EAAIW,EAAMlB,CAAE,EACP,CAAC9B,EAAUqC,CAAE,EACjB,GAAI,CACHA,EAAI,IAAI5B,EAAQ4B,CAAE,CACnB,OAAUE,EAAM,CACf,MAAM,IAAI,UAAW5B,EAAQ,2JAA4J0B,CAAE,CAAE,CAC9L,CAED3B,EAAS2B,EAAGJ,EAAO,EAAG,CAAE,EACxBV,EAAKC,EAAIZ,EAAQ,IAAK,EAAIqB,EAAO,CAAE,EACnCV,EAAKC,EAAIZ,EAAQ,GAAI,EAAIqB,EAAO,CAAE,EAClCT,GAAO,CACR,CACA,MACD,CACA,MAAM,IAAI,UAAWb,EAAQ,oTAAqTQ,CAAM,CAAE,CAG3V,CAAC,EAKD3B,EAAO,QAAU4B,ICp1BjB,IAAI8B,GAAO,IAKX,OAAO,QAAUA", - "names": ["require_indices", "__commonJSMin", "exports", "module", "isLittleEndian", "indices", "HIGH", "LOW", "require_from_iterator", "__commonJSMin", "exports", "module", "isUint64", "toWords", "Uint64", "format", "fromIterator", "it", "words", "out", "v", "u", "err", "require_from_iterator_map", "__commonJSMin", "exports", "module", "isUint64", "toWords", "Uint64", "format", "fromIteratorMap", "it", "clbk", "thisArg", "words", "out", "v", "i", "err", "require_from_array", "__commonJSMin", "exports", "module", "isUint64", "toWords", "Uint64", "format", "indices", "fromArray", "buf", "arr", "words", "len", "v", "j", "err", "require_main", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isBigInt", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "isUint64", "isInteger", "ITERATOR_SYMBOL", "setReadOnly", "setReadOnlyAccessor", "accessorGetter", "getter", "Uint32Array", "Number", "Uint64", "toWords", "format", "indices", "fromIterator", "fromIteratorMap", "fromArray", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isUint64Array", "value", "Uint64Array", "isUint64ArrayConstructor", "getUint64", "buf", "idx", "byteOffset", "nargs", "len", "tmp", "arg", "i", "src", "thisArg", "words", "clbk", "out", "get", "v", "j", "err", "args", "buffer", "self", "iter", "FLG", "next", "end", "factory", "sbuf", "N", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 6dd3c27..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,332 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 64-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0n, 0n, 0n, 0n, 0n ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5n, 5n, 5n ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > var arr1 = [ 5, 5, 5 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5n, 5n, 5n ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed 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: Uint64Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0n, 0n, 0n, 0n ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 1n, 2n ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint64Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1n, 2n ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint64Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 40 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both 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: Uint64|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ) - [ 1n, 2n ] - > var z = arr.at( 1 ) - [ 2n ] - - -{{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}}( [ 1, 2, 3 ] ) - [ 1n, 2n, 3n ] - > var it = arr.entries(); - > var v = it.next().value - [ 0, [ 1n ] ] - > v = it.next().value - [ 1, [ 2n ] ] - > v = it.next().value - [ 2, [ 3n ] ] - > var bool = it.next().done - 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: Uint64|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ) - [ 1n, 2n ] - > var z = arr.get( 1 ) - [ 2n ] - - -{{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. - - Parameters - ---------- - v: Uint64|number|bigint|ArrayLikeObject - Scalar or source array containing array values to set. - - i: integer (optional) - Array index at which to start setting elements. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( new {{alias:@stdlib/number/uint64/ctor}}( 4 ), 1 ); - > var z = arr.get( 1 ) - [ 4n ] - > arr.set( [ 5, 6 ], 1 ); - > z = arr.get( 1 ) - [ 5n ] - > z = arr.get( 2 ) - [ 6n ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 053b455..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,159 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Uint64 = require( '@stdlib/number-uint64-ctor' ); -import getLowWord = require( '@stdlib/number-uint64-base-get-low-word' ); -import getHighWord = require( '@stdlib/number-uint64-base-get-high-word' ); -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Uint64Array = require( './index' ); - -/** -* Callback function. -* -* @param v - input value -* @returns output value -*/ -function clbk( v: Uint64 ): Uint64 { - return Uint64.of( getHighWord( v ) * 2, getLowWord( v ) * 2 ); -} - - -// TESTS // - -// The function returns a 64-bit unsigned integer array... -{ - new Uint64Array(); // $ExpectType Uint64Array - Uint64Array(); // $ExpectType Uint64Array - new Uint64Array( 2 ); // $ExpectType Uint64Array - Uint64Array( 2 ); // $ExpectType Uint64Array - new Uint64Array( [ 1 ] ); // $ExpectType Uint64Array - Uint64Array( [ 1 ] ); // $ExpectType Uint64Array - - const buf = new ArrayBuffer( 8 ); - new Uint64Array( buf ); // $ExpectType Uint64Array - Uint64Array( buf ); // $ExpectType Uint64Array - new Uint64Array( buf, 4 ); // $ExpectType Uint64Array - Uint64Array( buf, 4 ); // $ExpectType Uint64Array - new Uint64Array( buf, 4, 1 ); // $ExpectType Uint64Array - Uint64Array( buf, 4, 1 ); // $ExpectType Uint64Array -} - -// 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 Uint64Array( true ); // $ExpectError - new Uint64Array( false ); // $ExpectError - new Uint64Array( null ); // $ExpectError - new Uint64Array( 'abc' ); // $ExpectError - new Uint64Array( {} ); // $ExpectError - new Uint64Array( ( x: number ): number => x ); // $ExpectError - - Uint64Array( true ); // $ExpectError - Uint64Array( false ); // $ExpectError - Uint64Array( null ); // $ExpectError - Uint64Array( 'abc' ); // $ExpectError - Uint64Array( {} ); // $ExpectError - Uint64Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 8 ); - new Uint64Array( buf, true ); // $ExpectError - new Uint64Array( buf, false ); // $ExpectError - new Uint64Array( buf, null ); // $ExpectError - new Uint64Array( buf, 'abc' ); // $ExpectError - new Uint64Array( buf, {} ); // $ExpectError - new Uint64Array( buf, ( x: number ): number => x ); // $ExpectError - - Uint64Array( buf, true ); // $ExpectError - Uint64Array( buf, false ); // $ExpectError - Uint64Array( buf, null ); // $ExpectError - Uint64Array( buf, 'abc' ); // $ExpectError - Uint64Array( buf, {} ); // $ExpectError - Uint64Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 8 ); - new Uint64Array( buf, 4, true ); // $ExpectError - new Uint64Array( buf, 4, false ); // $ExpectError - new Uint64Array( buf, 4, null ); // $ExpectError - new Uint64Array( buf, 4, 'abc' ); // $ExpectError - new Uint64Array( buf, 4, {} ); // $ExpectError - new Uint64Array( buf, 4, ( x: number ): number => x ); // $ExpectError - - Uint64Array( buf, 4, true ); // $ExpectError - Uint64Array( buf, 4, false ); // $ExpectError - Uint64Array( buf, 4, null ); // $ExpectError - Uint64Array( buf, 4, 'abc' ); // $ExpectError - Uint64Array( buf, 4, {} ); // $ExpectError - Uint64Array( buf, 4, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a 64-bit unsigned integer array... -{ - Uint64Array.from( [ 1 ] ); // $ExpectType Uint64Array - Uint64Array.from( [ 1 ], ( x: number ): number => x * x ); // $ExpectType Uint64Array - Uint64Array.from( [ new Uint64( 1 ) ], clbk, {} ); // $ExpectType Uint64Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Uint64Array.from( true ); // $ExpectError - Uint64Array.from( false ); // $ExpectError - Uint64Array.from( 123 ); // $ExpectError - Uint64Array.from( null ); // $ExpectError - Uint64Array.from( {} ); // $ExpectError - - Uint64Array.from( true, clbk ); // $ExpectError - Uint64Array.from( false, clbk ); // $ExpectError - Uint64Array.from( 123, clbk ); // $ExpectError - Uint64Array.from( null, clbk ); // $ExpectError - Uint64Array.from( {}, clbk ); // $ExpectError - - Uint64Array.from( true, clbk, {} ); // $ExpectError - Uint64Array.from( false, clbk, {} ); // $ExpectError - Uint64Array.from( 123, clbk, {} ); // $ExpectError - Uint64Array.from( null, clbk, {} ); // $ExpectError - Uint64Array.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... -{ - Uint64Array.from( [ 1 ], true ); // $ExpectError - Uint64Array.from( [ 1 ], false ); // $ExpectError - Uint64Array.from( [ 1 ], 123 ); // $ExpectError - Uint64Array.from( [ 1 ], null ); // $ExpectError - Uint64Array.from( [ 1 ], {} ); // $ExpectError -} - -// The `of` method returns a 64-bit unsigned integer array... -{ - Uint64Array.of( 1, 1, 1, 1 ); // $ExpectType Uint64Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Uint64Array.of( 'abc', 'def' ); // $ExpectError - Uint64Array.of( true, false ); // $ExpectError - Uint64Array.of( {}, [] ); // $ExpectError - Uint64Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 59b8e1d..0000000 --- a/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var logEach = require( '@stdlib/console-log-each' ); -var Uint64Array = require( './../lib' ); - -// Create a 64-bit unsigned integer array by specifying a length: -var out = new Uint64Array( 3 ); -logEach( '%s', out ); - -// Create a 64-bit unsigned integer array from an array of 64-bit unsigned integer numbers: -var arr = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ) -]; -out = new Uint64Array( arr ); -logEach( '%s', out ); - -// Create a 64-bit unsigned integer array from a typed array: -arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -out = new Uint64Array( arr ); -logEach( '%s', out ); - -// Create a 64-bit unsigned integer array from an array buffer, where underlying storage consists of interleaved high and low 32-bit words: -arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -out = new Uint64Array( arr.buffer ); -logEach( '%s', out ); - -// Create a 64-bit unsigned integer array from an array buffer view, where underlying storage represents each 64-bit integer as interleaved high and low 32-bit words: -arr = new Uint32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); -out = new Uint64Array( arr.buffer, 16, 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 cfb3c87..70eb395 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, Uint64Array as Uint64ArrayInterface } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bb94872 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-bigint@v0.2.4-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-uint64@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-integer@v0.2.7-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@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 g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint32@v0.2.3-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-ctor@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/number-uint64-ctor@v0.0.0-esm/index.mjs";import{assign as w}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-uint64-base-to-words@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.3-esm/index.mjs";var y,E;!0===v?(y=1,E=0):(y=0,E=1);var j={HIGH:y,LOW:E};function T(e){var t,r,n,i;for(t=[0,0],r=[];!(n=e.next()).done;){if(i=n.value,!f(i))try{i=new c(i)}catch(e){return new TypeError(p("invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.",i))}w(i,t,1,0),r.push(t[0],t[1])}return r}var _=2*m.BYTES_PER_ELEMENT,x=e();function L(e){return e instanceof R||"object"==typeof e&&null!==e&&"Uint64Array"===e.constructor.name&&e.BYTES_PER_ELEMENT===_&&"number"==typeof e._length&&"object"==typeof e._buffer}function H(e){return e===R}function O(e,t){return t*=2,c.of(e[t+j.HIGH],e[t+j.LOW])}function R(){var e,t,u,d,g,b,v;if(t=arguments.length,!(this instanceof R))return 0===t?new R:1===t?new R(arguments[0]):2===t?new R(arguments[0],arguments[1]):new R(arguments[0],arguments[1],arguments[2]);if(0===t)u=new m(0);else if(1===t)if(r(b=arguments[0]))u=new m(2*b);else if(n(b)){if(d=b.length,L(b))u=new m(b._buffer);else if(u=function(e,t){var r,n,i,s,o;for(r=[0,0],n=t.length,o=0,s=0;su.byteLength-e)throw new RangeError(p("null2G",d*_));u=new m(u,e,2*d)}}return a(this,"_buffer",u),a(this,"_length",u.length/2),this}a(R,"BYTES_PER_ELEMENT",_),a(R,"name","Uint64Array"),a(R,"from",(function(e){var t,r,i,h,a,u,m,b,v,y,E,_;if(!o(this))throw new TypeError(p("null01"));if(!H(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if((r=arguments.length)>1){if(!o(h=arguments[1]))throw new TypeError(p("null2H",h));r>2&&(t=arguments[2])}if(n(e)){if(h){for(v=e.length,b=e.get&&e.set?d("default"):g("default"),u=(a=new this(v))._buffer,i=[0,0],_=0,E=0;E=this._length))return O(this._buffer,e)})),u(R.prototype,"buffer",(function(){return this._buffer.buffer})),u(R.prototype,"byteLength",(function(){return this._buffer.byteLength})),u(R.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),a(R.prototype,"BYTES_PER_ELEMENT",R.BYTES_PER_ELEMENT),a(R.prototype,"entries",(function(){var e,t,r,n,i,s;if(!L(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");return t=this,e=this._buffer,n=this._length,s=-1,a(r={},"next",(function(){if(s+=1,i||s>=n)return{done:!0};return{value:[s,O(e,s)],done:!1}})),a(r,"return",(function(e){if(i=!0,arguments.length)return{value:e,done:!0};return{done:!0}})),l&&a(r,l,(function(){return t.entries()})),r})),a(R.prototype,"get",(function(e){if(!L(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if(!r(e))throw new TypeError(p("null2K",e));if(!(e>=this._length))return O(this._buffer,e)})),u(R.prototype,"length",(function(){return this._length})),a(R.prototype,"set",(function(e){var i,s,o,h,l,a,u,d,g;if(!L(this))throw new TypeError("invalid invocation. `this` is not a 64-bit unsigned integer array.");if(h=this._buffer,arguments.length>1){if(!r(o=arguments[1]))throw new TypeError(p("null2L",o))}else o=0;if(i=[0,0],f(e)){if(o>=this._length)throw new RangeError(p("null2M",o));return o*=2,w(e,i,1,0),h[o+j.HIGH]=i[0],void(h[o+j.LOW]=i[1])}if(r(e)||t(e)&&r(b(e))){if(o>=this._length)throw new RangeError(p("null2M",o));return e=new c(e),o*=2,w(e,i,1,0),h[o+j.HIGH]=i[0],void(h[o+j.LOW]=i[1])}if(L(e)){if(o+(a=e._length)>this._length)throw new RangeError(p("null03"));if(s=e._buffer,g=h.byteOffset+o*_,s.buffer===h.buffer&&s.byteOffsetg){for(l=new m(s.length),d=0;dthis._length)throw new RangeError(p("null03"));if(s=e,g=h.byteOffset+o*_,s.buffer===h.buffer&&s.byteOffsetg){for(l=new m(s.length),d=0;d\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Uint64Array( 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Uint64Array( [ 1, 2 ] );\n* // returns [ 1n, 2n ]\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( 32 );\n* var arr = new Uint64Array( buf );\n* // returns [ 0n, 0n, 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Uint64Array( buf, 16 );\n* // returns [ 0n, 0n ]\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( 64 );\n* var arr = new Uint64Array( buf, 16, 2 );\n* // returns [ 0n, 0n ]\n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Uint64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar tmp;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Uint64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Uint64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Uint64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Uint64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Uint64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint32Array( arg*2 );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tlen = arg.length;\n\t\t\tif ( isUint64Array( arg ) ) {\n\t\t\t\t// Source is already arranged as high/low words, so just copy buffer to buffer:\n\t\t\t\tbuf = new Uint32Array( arg._buffer ); // eslint-disable-line no-underscore-dangle\n\t\t\t} else {\n\t\t\t\t// Assume that every element represents a single 64-bit unsigned integer:\n\t\t\t\tbuf = fromArray( new Uint32Array( len*2 ), arg );\n\t\t\t\tif ( buf instanceof Error ) {\n\t\t\t\t\tthrow buf;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint32Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tbuf = arg;\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tlen = buf.length;\n\t\t\ttmp = new Uint32Array( len );\n\t\t\tfor ( i = 0; i < len; i += 2 ) {\n\t\t\t\ttmp[ i+indices.HIGH ] = buf[ i ];\n\t\t\t\ttmp[ i+indices.LOW ] = buf[ i+1 ];\n\t\t\t}\n\t\t\tbuf = tmp;\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 ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint32Array( 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 Uint32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Uint64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Uint64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Uint64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Uint64Array\n* @readonly\n* @type {string}\n* @default 'Uint64Array'\n*\n* @example\n* var name = Uint64Array.name;\n* // returns 'Uint64Array'\n*/\nsetReadOnly( Uint64Array, 'name', 'Uint64Array' );\n\n/**\n* Creates a new 64-bit unsigned integer array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Uint64Array\n* @type {Function}\n* @param {(Collection|Object)} 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 64-bit unsigned integer 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* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} an iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} when provided an iterator, a callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @returns {Uint64Array} 64-bit unsigned integer array\n*\n* @example\n* var arr = Uint64Array.from( [ 1, 2, 3 ] );\n* // returns [ 1n, 2n, 3n ]\n*\n* var len = arr.length;\n* // returns 3\n*\n* @example\n* import Uint64 from '@stdlib/number-uint64-ctor';\n*\n* var arr = Uint64Array.from( [ new Uint64( 1 ) ] );\n* // returns [ 1n ]\n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Uint64 from '@stdlib/number-uint64-ctor';\n* import add from '@stdlib/number-uint64-base-add';\n*\n* function clbk( v ) {\n* return add( v, v );\n* }\n*\n* var arr = Uint64Array.from( [ new Uint64( 1 ) ], clbk );\n* // returns [ 2n ]\n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Uint64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar words;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isUint64ArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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\n\t\t\twords = [ 0, 0 ];\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( !isUint64( v ) ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tv = new Uint64( v );\n\t\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\t\tthrow new TypeError( format( 'invalid argument. A callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttoWords( v, words, 1, 0 );\n\t\t\t\tbuf[ j+indices.HIGH ] = words[ 0 ];\n\t\t\t\tbuf[ j+indices.LOW ] = words[ 1 ];\n\t\t\t\tj += 2; // stride\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\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < tmp.length; i += 2 ) {\n\t\t\tbuf[ i+indices.HIGH ] = tmp[ i ];\n\t\t\tbuf[ i+indices.LOW ] = tmp[ i+1 ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 64-bit unsigned integer array from a variable number of arguments.\n*\n* @name of\n* @memberof Uint64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @returns {Uint64Array} 64-bit unsigned integer array\n*\n* @example\n* var arr = Uint64Array.of( 1, 2, 3, 4 );\n* // returns [ 1n, 2n, 3n, 4n ]\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Uint64Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isUint64ArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 Uint64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @throws {TypeError} must provide an integer\n* @returns {(Uint64|void)} array element\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var u = arr.at( 0 );\n* // returns [ 0n ]\n*\n* arr.set( 1, 0 );\n* arr.set( 2, 1 );\n* arr.set( 9, 9 );\n*\n* u = arr.at( 0 );\n* // returns [ 1n ]\n*\n* u = arr.at( -1 );\n* // returns [ 9n ]\n*\n* u = arr.at( 100 );\n* // returns undefined\n*\n* u = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Uint64Array.prototype, 'at', function at( idx ) {\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getUint64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Uint64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Uint64Array.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 Uint64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_ELEMENT );\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Uint64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @returns {Iterator} iterator\n*\n* @example\n* import Uint64 from '@stdlib/number-uint64-ctor';\n*\n* var arr = [\n* new Uint64( 1 ),\n* new Uint64( 2 ),\n* new Uint64( 3 )\n* ];\n* arr = new Uint64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, [ 1n ] ]\n*\n* v = it.next().value;\n* // returns [ 1, [ 2n ] ]\n*\n* v = it.next().value;\n* // returns [ 2, [ 3n ] ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Uint64Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' );\n\t}\n\tself = this;\n\tbuffer = 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, getUint64( buffer, 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* Returns an array element.\n*\n* @name get\n* @memberof Uint64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a 64-bit unsigned integer array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Uint64|void)} array element\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns [ 0n ]\n*\n* arr.set( [ 1 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns [ 1n ]\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Uint64Array.prototype, 'get', function get( idx ) {\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 getUint64( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Uint64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Uint64Array.prototype, 'length', function get() {\n\treturn this._length;\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 Uint64Array.prototype\n* @type {Function}\n* @param {(Collection|Uint64Array|Uint64|bigint|number)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a 64-bit unsigned integer 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* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer\n* @throws {TypeError} first argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers\n* @returns {void}\n*\n* @example\n* var arr = new Uint64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns [ 0n ]\n*\n* arr.set( 1n, 0 );\n*\n* z = arr.get( 0 );\n* // returns [ 1n ]\n*/\nsetReadOnly( Uint64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar words;\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isUint64Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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\twords = [ 0, 0 ];\n\tif ( isUint64( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'null2M', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\ttoWords( value, words, 1, 0 );\n\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\treturn;\n\t}\n\tif ( isNonNegativeInteger( value ) || ( isBigInt( value ) && isNonNegativeInteger( Number( value ) ) ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'null2M', idx ) );\n\t\t}\n\t\tvalue = new Uint64( value );\n\t\tidx *= 2;\n\t\ttoWords( value, words, 1, 0 );\n\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\treturn;\n\t}\n\tif ( isUint64Array( 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\tsbuf = value._buffer;\n\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 Uint32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx+indices.HIGH ] = sbuf[ j+indices.HIGH ];\n\t\t\tbuf[ idx+indices.LOW ] = sbuf[ j+indices.LOW ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\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\tsbuf = value;\n\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 Uint32Array( 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\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = sbuf[ i ];\n\t\t\tif ( !isUint64( v ) ) {\n\t\t\t\ttry {\n\t\t\t\t\tv = new Uint64( v );\n\t\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. An array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoWords( v, words, 1, 0 );\n\t\t\tbuf[ idx+indices.HIGH ] = words[ 0 ];\n\t\t\tbuf[ idx+indices.LOW ] = words[ 1 ];\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n\n// EXPORTS //\n\nexport default Uint64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isUint64 from '@stdlib/assert-is-uint64';\nimport { assign as toWords } from '@stdlib/number-uint64-base-to-words';\nimport Uint64 from '@stdlib/number-uint64-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport indices from './indices.js';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of high and low words.\n*\n* @private\n* @param {Uint32Array} buf - output array\n* @param {Array} arr - array containing 64-bit unsigned integers\n* @returns {(Uint32Array|TypeError)} output array or an error\n*/\nfunction fromArray( buf, arr ) {\n\tvar words;\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\t// Workspace for storing high and low words:\n\twords = [ 0, 0 ];\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isUint64( v ) ) {\n\t\t\ttry {\n\t\t\t\tv = new Uint64( v );\n\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\treturn new TypeError( format( 'invalid argument. An array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\ttoWords( v, words, 1, 0 );\n\t\tbuf[ j+indices.HIGH ] = words[ 0 ];\n\t\tbuf[ j+indices.LOW ] = words[ 1 ];\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 isUint64 from '@stdlib/assert-is-uint64';\nimport { assign as toWords } from '@stdlib/number-uint64-base-to-words';\nimport Uint64 from '@stdlib/number-uint64-ctor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\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|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar words;\n\tvar out;\n\tvar v;\n\tvar u;\n\tvar i;\n\n\t// Workspace for storing high and low words:\n\twords = [ 0, 0 ];\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\tu = clbk.call( thisArg, v.value, i );\n\t\tif ( !isUint64( u ) ) {\n\t\t\ttry {\n\t\t\t\tu = new Uint64( u );\n\t\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', u ) );\n\t\t\t}\n\t\t}\n\t\ttoWords( u, words, 1, 0 );\n\t\tout.push( words[ 0 ], words[ 1 ] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n"],"names":["HIGH","LOW","isLittleEndian","indices$1","fromIterator","it","words","out","v","u","next","done","value","isUint64","Uint64","err","TypeError","format","toWords","push","BYTES_PER_ELEMENT","Uint32Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isUint64Array","Uint64Array","constructor","name","_length","_buffer","isUint64ArrayConstructor","getUint64","buf","idx","of","indices","byteOffset","nargs","len","tmp","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","arr","j","fromArray","Error","isArrayBuffer","isInteger","byteLength","RangeError","isObject","isFunction","ITERATOR_SYMBOL","setReadOnly","src","thisArg","clbk","get","set","accessorGetter","getter","call","fromIteratorMap","args","prototype","setReadOnlyAccessor","buffer","self","iter","FLG","entries","sbuf","N","isBigInt","Number"],"mappings":";;g8DA2BA,IACIA,EACAC,GAEoB,IAAnBC,GACJF,EAAO,EACPC,EAAM,IAEND,EAAO,EACPC,EAAM,GAUP,IAAAE,EARU,CACTH,KAAQA,EACRC,IAAOA,GCHR,SAASG,EAAcC,GACtB,IAAIC,EACAC,EACAC,EACAC,EAMJ,IAHAH,EAAQ,CAAE,EAAG,GAEbC,EAAM,KAELC,EAAIH,EAAGK,QACAC,MAFO,CAMd,GADAF,EAAID,EAAEI,OACAC,EAAUJ,GACf,IACCA,EAAI,IAAIK,EAAQL,EAChB,CAAC,MAAQM,GACT,OAAO,IAAIC,UAAWC,EAAQ,0JAA2JR,GACzL,CAEFS,EAAST,EAAGH,EAAO,EAAG,GACtBC,EAAIY,KAAMb,EAAO,GAAKA,EAAO,GAC7B,CACD,OAAOC,CACR,CCbA,IAAAa,EAAA,EAAAC,EAAAD,kBACAE,EAAAC,IAYA,SAAAC,EAAAZ,GACA,OACAA,aAAAa,GAEA,iBAAAb,GACA,OAAAA,GACA,gBAAAA,EAAAc,YAAAC,MACAf,EAAAQ,oBAAAA,GACA,iBAAAR,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AA,IAAAC,UAAAC,EAAA,2JAAAT,GACA,CAEAU,EAAAV,EAAAF,EAAA,EAAA,GACA0B,EAAAC,EAAAE,EAAAnC,MAAAM,EAAA,GACA0B,EAAAC,EAAAE,EAAAlC,KAAAK,EAAA,GACA2B,GAAA,CACA,CAtCA,CA4CA"} \ No newline at end of file diff --git a/lib/from_array.js b/lib/from_array.js deleted file mode 100644 index ba064fd..0000000 --- a/lib/from_array.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUint64 = require( '@stdlib/assert-is-uint64' ); -var toWords = require( '@stdlib/number-uint64-base-to-words' ).assign; -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var format = require( '@stdlib/string-format' ); -var indices = require( './indices.js' ); - - -// MAIN // - -/** -* Returns a strided array of high and low words. -* -* @private -* @param {Uint32Array} buf - output array -* @param {Array} arr - array containing 64-bit unsigned integers -* @returns {(Uint32Array|TypeError)} output array or an error -*/ -function fromArray( buf, arr ) { - var words; - var len; - var v; - var i; - var j; - - // Workspace for storing high and low words: - words = [ 0, 0 ]; - - len = arr.length; - j = 0; - for ( i = 0; i < len; i++ ) { - v = arr[ i ]; - if ( !isUint64( v ) ) { - try { - v = new Uint64( v ); - } catch ( err ) { // eslint-disable-line no-unused-vars - return new TypeError( format( 'invalid argument. An array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) ); - } - } - toWords( v, words, 1, 0 ); - buf[ j+indices.HIGH ] = words[ 0 ]; - buf[ j+indices.LOW ] = words[ 1 ]; - j += 2; // stride - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index 91ebe52..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUint64 = require( '@stdlib/assert-is-uint64' ); -var toWords = require( '@stdlib/number-uint64-base-to-words' ).assign; -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {(Array|TypeError)} array or an error -*/ -function fromIterator( it ) { - var words; - var out; - var v; - var u; - - // Workspace for storing high and low words: - words = [ 0, 0 ]; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - u = v.value; - if ( !isUint64( u ) ) { - try { - u = new Uint64( u ); - } catch ( err ) { // eslint-disable-line no-unused-vars - return new TypeError( format( 'invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', u ) ); - } - } - toWords( u, words, 1, 0 ); - out.push( words[ 0 ], words[ 1 ] ); - } - 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 4650fe7..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isUint64 = require( '@stdlib/assert-is-uint64' ); -var toWords = require( '@stdlib/number-uint64-base-to-words' ).assign; -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var format = require( '@stdlib/string-format' ); - - -// 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|TypeError)} array or an error -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var words; - var out; - var v; - var u; - var i; - - // Workspace for storing high and low words: - words = [ 0, 0 ]; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - u = clbk.call( thisArg, v.value, i ); - if ( !isUint64( u ) ) { - try { - u = new Uint64( u ); - } catch ( err ) { // eslint-disable-line no-unused-vars - return new TypeError( format( 'invalid argument. An iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', u ) ); - } - } - toWords( u, words, 1, 0 ); - out.push( words[ 0 ], words[ 1 ] ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index b35c87d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 64-bit unsigned integer array. -* -* @module @stdlib/array-uint64 -* -* @example -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var arr = new Uint64Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var arr = new Uint64Array( 2 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var arr = new Uint64Array( [ 1 ] ); -* // returns [ 1n ] -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Uint64Array( buf ); -* // returns [ 0n, 0n, 0n, 0n ] -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Uint64Array( buf, 16 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Uint64Array = require( '@stdlib/array-uint64' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = new Uint64Array( buf, 16, 2 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/indices.js b/lib/indices.js deleted file mode 100644 index 42c6890..0000000 --- a/lib/indices.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isLittleEndian = require( '@stdlib/assert-is-little-endian' ); - - -// MAIN // - -var indices; -var HIGH; -var LOW; - -if ( isLittleEndian === true ) { - HIGH = 1; // second index - LOW = 0; // first index -} else { - HIGH = 0; // first index - LOW = 1; // second index -} -indices = { - 'HIGH': HIGH, - 'LOW': LOW -}; - - -// EXPORTS // - -module.exports = indices; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 7efaaa1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,941 +0,0 @@ -/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isBigInt = require( '@stdlib/assert-is-bigint' ).isPrimitive; -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 isUint64 = require( '@stdlib/assert-is-uint64' ); -var isInteger = require( '@stdlib/math-base-assert-is-integer' ); -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 accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var getter = require( '@stdlib/array-base-getter' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Number = require( '@stdlib/number-ctor' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var toWords = require( '@stdlib/number-uint64-base-to-words' ).assign; -var format = require( '@stdlib/string-format' ); -var indices = require( './indices.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); -var fromArray = require( './from_array.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint32Array.BYTES_PER_ELEMENT * 2; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a 64-bit unsigned integer array. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a unsigned typed array -*/ -function isUint64Array( value ) { - return ( - value instanceof Uint64Array || - ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Uint64Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT && - typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle - - // NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks... - typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle - ) - ); -} - -/** -* Returns a boolean indicating if a value is a 64-bit unsigned integer typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a 64-bit unsigned integer typed array constructor -*/ -function isUint64ArrayConstructor( value ) { - return ( value === Uint64Array ); -} - -/** -* Retrieves a 64-bit unsigned integer from a 32-bit unsigned integer array buffer. -* -* @private -* @param {Uint32Array} buf - array buffer -* @param {NonNegativeInteger} idx - element index -* @returns {Uint64} 64-bit unsigned integer -*/ -function getUint64( buf, idx ) { - idx *= 2; - return Uint64.of( buf[ idx+indices.HIGH ], buf[ idx+indices.LOW ] ); -} - - -// MAIN // - -/** -* 64-bit unsigned integer array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `8` -* @throws {TypeError} view length must be a positive multiple of `8` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @throws {TypeError} an iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @returns {Uint64Array} 64-bit unsigned integer array -* -* @example -* var arr = new Uint64Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Uint64Array( 2 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Uint64Array( [ 1, 2 ] ); -* // returns [ 1n, 2n ] -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Uint64Array( buf ); -* // returns [ 0n, 0n, 0n, 0n ] -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Uint64Array( buf, 16 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = new Uint64Array( buf, 16, 2 ); -* // returns [ 0n, 0n ] -* -* var len = arr.length; -* // returns 2 -*/ -function Uint64Array() { - var byteOffset; - var nargs; - var buf; - var len; - var tmp; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Uint64Array) ) { - if ( nargs === 0 ) { - return new Uint64Array(); - } - if ( nargs === 1 ) { - return new Uint64Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Uint64Array( arguments[0], arguments[1] ); - } - return new Uint64Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint32Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint32Array( arg*2 ); - } else if ( isCollection( arg ) ) { - len = arg.length; - if ( isUint64Array( arg ) ) { - // Source is already arranged as high/low words, so just copy buffer to buffer: - buf = new Uint32Array( arg._buffer ); // eslint-disable-line no-underscore-dangle - } else { - // Assume that every element represents a single 64-bit unsigned integer: - buf = fromArray( new Uint32Array( len*2 ), arg ); - if ( buf instanceof Error ) { - throw buf; - } - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint32Array( arg ); - } else if ( isObject( arg ) ) { - buf = 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`.', buf ) ); - } - if ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); - } - buf = buf[ 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`.', buf ) ); - } - buf = fromIterator( buf ); - if ( buf instanceof Error ) { - throw buf; - } - len = buf.length; - tmp = new Uint32Array( len ); - for ( i = 0; i < len; i += 2 ) { - tmp[ i+indices.HIGH ] = buf[ i ]; - tmp[ i+indices.LOW ] = buf[ i+1 ]; - } - buf = tmp; - } 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 ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint32Array( 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 Uint32Array( buf, byteOffset, len*2 ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length/2 ); - - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Uint64Array -* @readonly -* @type {PositiveInteger} -* @default 8 -* -* @example -* var nbytes = Uint64Array.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Uint64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Uint64Array -* @readonly -* @type {string} -* @default 'Uint64Array' -* -* @example -* var name = Uint64Array.name; -* // returns 'Uint64Array' -*/ -setReadOnly( Uint64Array, 'name', 'Uint64Array' ); - -/** -* Creates a new 64-bit unsigned integer array from an array-like object or an iterable. -* -* @name from -* @memberof Uint64Array -* @type {Function} -* @param {(Collection|Object)} 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 64-bit unsigned integer array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @throws {TypeError} an iterator must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @throws {TypeError} when provided an iterator, a callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @returns {Uint64Array} 64-bit unsigned integer array -* -* @example -* var arr = Uint64Array.from( [ 1, 2, 3 ] ); -* // returns [ 1n, 2n, 3n ] -* -* var len = arr.length; -* // returns 3 -* -* @example -* var Uint64 = require( '@stdlib/number-uint64-ctor' ); -* -* var arr = Uint64Array.from( [ new Uint64( 1 ) ] ); -* // returns [ 1n ] -* -* var len = arr.length; -* // returns 1 -* -* @example -* var Uint64 = require( '@stdlib/number-uint64-ctor' ); -* var add = require( '@stdlib/number-uint64-base-add' ); -* -* function clbk( v ) { -* return add( v, v ); -* } -* -* var arr = Uint64Array.from( [ new Uint64( 1 ) ], clbk ); -* // returns [ 2n ] -* -* var len = arr.length; -* // returns 1 -*/ -setReadOnly( Uint64Array, 'from', function from( src ) { - var thisArg; - var nargs; - var words; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var v; - var i; - var j; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isUint64ArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 - - words = [ 0, 0 ]; - j = 0; - for ( i = 0; i < len; i++ ) { - v = clbk.call( thisArg, get( src, i ), i ); - if ( !isUint64( v ) ) { - try { - v = new Uint64( v ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. A callback must return either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) ); - } - } - toWords( v, words, 1, 0 ); - buf[ j+indices.HIGH ] = words[ 0 ]; - buf[ j+indices.LOW ] = words[ 1 ]; - j += 2; // stride - } - 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 ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length / 2; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < tmp.length; i += 2 ) { - buf[ i+indices.HIGH ] = tmp[ i ]; - buf[ i+indices.LOW ] = tmp[ i+1 ]; - } - 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 64-bit unsigned integer array from a variable number of arguments. -* -* @name of -* @memberof Uint64Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a 64-bit unsigned integer array -* @returns {Uint64Array} 64-bit unsigned integer array -* -* @example -* var arr = Uint64Array.of( 1, 2, 3, 4 ); -* // returns [ 1n, 2n, 3n, 4n ] -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Uint64Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isUint64ArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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 Uint64Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a 64-bit unsigned integer array -* @throws {TypeError} must provide an integer -* @returns {(Uint64|void)} array element -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var u = arr.at( 0 ); -* // returns [ 0n ] -* -* arr.set( 1, 0 ); -* arr.set( 2, 1 ); -* arr.set( 9, 9 ); -* -* u = arr.at( 0 ); -* // returns [ 1n ] -* -* u = arr.at( -1 ); -* // returns [ 9n ] -* -* u = arr.at( 100 ); -* // returns undefined -* -* u = arr.at( -100 ); -* // returns undefined -*/ -setReadOnly( Uint64Array.prototype, 'at', function at( idx ) { - if ( !isUint64Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return getUint64( this._buffer, idx ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Uint64Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Uint64Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Uint64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 80 -*/ -setReadOnlyAccessor( Uint64Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Uint64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Uint64Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Uint64Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 8 -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Uint64Array.prototype, 'BYTES_PER_ELEMENT', Uint64Array.BYTES_PER_ELEMENT ); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Uint64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a 64-bit unsigned integer array -* @returns {Iterator} iterator -* -* @example -* var Uint64 = require( '@stdlib/number-uint64-ctor' ); -* -* var arr = [ -* new Uint64( 1 ), -* new Uint64( 2 ), -* new Uint64( 3 ) -* ]; -* arr = new Uint64Array( arr ); -* -* // Create an iterator: -* var it = arr.entries(); -* -* // Iterate over the key-value pairs... -* var v = it.next().value; -* // returns [ 0, [ 1n ] ] -* -* v = it.next().value; -* // returns [ 1, [ 2n ] ] -* -* v = it.next().value; -* // returns [ 2, [ 3n ] ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Uint64Array.prototype, 'entries', function entries() { - var buffer; - var self; - var iter; - var len; - var FLG; - var i; - if ( !isUint64Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); - } - self = this; - buffer = 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, getUint64( buffer, 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(); - } -}); - -/** -* Returns an array element. -* -* @name get -* @memberof Uint64Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a 64-bit unsigned integer array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(Uint64|void)} array element -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var z = arr.get( 0 ); -* // returns [ 0n ] -* -* arr.set( [ 1 ], 0 ); -* -* z = arr.get( 0 ); -* // returns [ 1n ] -* -* z = arr.get( 100 ); -* // returns undefined -*/ -setReadOnly( Uint64Array.prototype, 'get', function get( idx ) { - if ( !isUint64Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return getUint64( this._buffer, idx ); -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Uint64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Uint64Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* 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 Uint64Array.prototype -* @type {Function} -* @param {(Collection|Uint64Array|Uint64|bigint|number)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a 64-bit unsigned integer 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 -* @throws {TypeError} an array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer -* @throws {TypeError} first argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers -* @returns {void} -* -* @example -* var arr = new Uint64Array( 10 ); -* -* var z = arr.get( 0 ); -* // returns [ 0n ] -* -* arr.set( 1n, 0 ); -* -* z = arr.get( 0 ); -* // returns [ 1n ] -*/ -setReadOnly( Uint64Array.prototype, 'set', function set( value ) { - /* eslint-disable no-underscore-dangle */ - var words; - var sbuf; - var idx; - var buf; - var tmp; - var N; - var v; - var i; - var j; - if ( !isUint64Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a 64-bit unsigned integer 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; - } - words = [ 0, 0 ]; - if ( isUint64( value ) ) { - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - idx *= 2; - toWords( value, words, 1, 0 ); - buf[ idx+indices.HIGH ] = words[ 0 ]; - buf[ idx+indices.LOW ] = words[ 1 ]; - return; - } - if ( isNonNegativeInteger( value ) || ( isBigInt( value ) && isNonNegativeInteger( Number( value ) ) ) ) { - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - value = new Uint64( value ); - idx *= 2; - toWords( value, words, 1, 0 ); - buf[ idx+indices.HIGH ] = words[ 0 ]; - buf[ idx+indices.LOW ] = words[ 1 ]; - return; - } - if ( isUint64Array( value ) ) { - N = value._length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value._buffer; - - // 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 Uint32Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - idx *= 2; - j = 0; - for ( i = 0; i < N; i++ ) { - buf[ idx+indices.HIGH ] = sbuf[ j+indices.HIGH ]; - buf[ idx+indices.LOW ] = sbuf[ j+indices.LOW ]; - idx += 2; // stride - j += 2; // stride - } - return; - } - 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.' ); - } - 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 Uint32Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays - } - sbuf = tmp; - } - idx *= 2; - for ( i = 0; i < N; i++ ) { - v = sbuf[ i ]; - if ( !isUint64( v ) ) { - try { - v = new Uint64( v ); - } catch ( err ) { // eslint-disable-line no-unused-vars - throw new TypeError( format( 'invalid argument. An array element must be either a 64-bit unsigned integer or a value which can be converted to a 64-bit unsigned integer. Value: `%s`.', v ) ); - } - } - toWords( v, words, 1, 0 ); - buf[ idx+indices.HIGH ] = words[ 0 ]; - buf[ idx+indices.LOW ] = words[ 1 ]; - idx += 2; // stride - } - return; - } - throw new TypeError( format( 'invalid argument. First argument must be either a 64-bit unsigned integer, a value which can be converted to a 64-bit unsigned integer, a 64-bit unsigned integer array, or an array-like object containing 64-bit unsigned integers or values which can be converted to a 64-bit unsigned integers. Value: `%s`.', value ) ); - - /* eslint-enable no-underscore-dangle */ -}); - - -// EXPORTS // - -module.exports = Uint64Array; diff --git a/package.json b/package.json index 254535e..1634902 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Uint64Array.", "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-uint32": "^0.2.3", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-bigint": "^0.2.4", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-little-endian": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-uint64": "github:stdlib-js/assert-is-uint64#main", - "@stdlib/math-base-assert-is-integer": "^0.2.7", - "@stdlib/number-ctor": "^0.2.3", - "@stdlib/number-uint64-base-to-words": "github:stdlib-js/number-uint64-base-to-words#main", - "@stdlib/number-uint64-ctor": "github:stdlib-js/number-uint64-ctor#main", - "@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/array-float64": "^0.2.3", - "@stdlib/array-zero-to": "^0.2.3", - "@stdlib/assert-has-bigint-support": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/bigint-ctor": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/number-uint64-base-add": "github:stdlib-js/number-uint64-base-add#main", - "@stdlib/number-uint64-base-assert-is-equal": "github:stdlib-js/number-uint64-base-assert-is-equal#main", - "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..79088fd --- /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 c8a702e..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isEqual = require( '@stdlib/number-uint64-base-assert-is-equal' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, '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( Uint64Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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 Uint64Array( 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 Uint64Array( 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 arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Uint64( i ) ); - } - arr = new Uint64Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( isEqual( v, new Uint64( arr.length+i ) ), true, 'returns expected value for index '+i ); - } else { - t.strictEqual( isEqual( v, new Uint64( i ) ), true, 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 704a23a..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var proxyquire = require( 'proxyquire' ); -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isUint64 = require( '@stdlib/assert-is-uint64' ); -var isEqual = require( '@stdlib/number-uint64-base-assert-is-equal' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, '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( Uint64Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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 = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ), - new Uint64( 4 ) - ]; - arr = new Uint64Array( 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 an index' ); - t.strictEqual( isUint64( v.value[ 1 ] ), true, 'returns a 64-bit unsigned integer' ); - t.strictEqual( isEqual( v.value[ 1 ], buf[ i ] ), true, '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 = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ), - new Uint64( 4 ) - ]; - arr = new Uint64Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( isEqual( v.value[ 1 ], buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( isEqual( v.value[ 1 ], buf[ 1 ] ), true, '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 = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ), - new Uint64( 4 ) - ]; - arr = new Uint64Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( isEqual( v.value[ 1 ], buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( isEqual( v.value[ 1 ], buf[ 1 ] ), true, '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 Uint64Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ), - new Uint64( 4 ) - ]; - arr = new Uint64Array( 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( isEqual( v1[ 0 ], v2[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isEqual( v1[ 1 ], v2[ 1 ] ), true, '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 Uint64Array; - var arr; - var buf; - var it; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol-iterator': false - }); - - buf = [ - new Uint64( 1 ), - new Uint64( 2 ), - new Uint64( 3 ), - new Uint64( 4 ) - ]; - arr = new Uint64Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index c1620cc..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,923 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var add = require( '@stdlib/number-uint64-base-add' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint64Array = require( './../lib' ); - - -// VARIABLES // - -var HAS_BIGINTS = hasBigIntSupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 64-bit unsigned integer array from an array-like object or iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Uint64Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.from ), true, 'has method' ); - - arr = Uint64Array.from( [] ); - t.strictEqual( arr instanceof Uint64Array, 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 Uint64Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a unsigned integer array constructor', function test( t ) { - var values; - var i; - - values = [ - Uint64, - 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 Uint64Array.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 Uint64Array.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 Uint64Array.from( value, clbk ); - }; - } - - function clbk() { - return new Uint64( 1 ); - } -}); - -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 Uint64Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return new Uint64( 1 ); - } -}); - -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 Uint64Array.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 Uint64Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a 64-bit unsigned integer array', function test( t ) { - var arr; - var v; - var u; - - // Generic array: - arr = Uint64Array.from( [] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( [ 1, 2, 3, 4 ] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing 64-bit unsigned integers: - arr = Uint64Array.from( [ new Uint64( 1 ) ] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - u = new Uint64( 1 ); - arr = Uint64Array.from( [ u, 1.0 ] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Uint64Array.from( new Float64Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( new Float64Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Unsigned integer typed array: - arr = Uint64Array.from( new Uint32Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( new Uint32Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Uint64Array.from( new Uint64Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( new Uint64Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a 64-bit unsigned integer array (iterable)', function test( t ) { - var Uint64Array; - var iter1; - var iter2; - var iter3; - var arr; - var v; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - - arr = Uint64Array.from( createIterable( iter1 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - - arr = Uint64Array.from( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - - arr = Uint64Array.from( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - if ( HAS_BIGINTS ) { - iter3 = { - 'next': next3, - 'i': 0, - 'N': 4 - }; - - arr = Uint64Array.from( createIterable( iter3 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter3.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 next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': new Uint64( 1 ) - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': 1 - }; - } - return { - 'done': true - }; - } - - function next3() { - iter3.i += 1; - if ( iter3.i <= iter3.N ) { - return { - 'value': BigInt( 1 ) - }; - } - 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 = Uint64Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( [ 1, 2, 3, 4 ], clbk1 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing 64-bit unsigned integers: - arr = Uint64Array.from( [ new Uint64( 1 ) ], clbk2 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Uint64Array.from( [ new Uint64( 1 ) ], clbk3 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = Uint64Array.from( new Float64Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( new Float64Array( [ 1.0, 1.0 ] ), clbk1 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Unsigned typed array: - arr = Uint64Array.from( new Uint64Array( 0 ), clbk3 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Uint64Array.from( new Uint64Array( [ 1, 1 ] ), clbk3 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return new Uint64( 1 ); - } - - function clbk3( v ) { - return add( v, v ); - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Uint64Array; - var iter1; - var iter2; - var arr; - var v; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = Uint64Array.from( createIterable( iter1 ), clbk ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = Uint64Array.from( createIterable( iter2 ), clbk ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.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 next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': new Uint64( 1 ) - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': 1 - }; - } - return { - 'done': true - }; - } - - function clbk() { - return 1; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Uint64Array.from( [ 1, 2, 3, 4 ], clbk1, ctx ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - ctx = { - 'count': 0 - }; - arr = [ new Uint64( 1 ), new Uint64( 2 ) ]; - arr = Uint64Array.from( arr, clbk2, ctx ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return add( v, new Uint64( 1 ) ); - } - - function clbk2( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return add( v, v ); - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Uint64Array; - var iter; - var ctx; - var arr; - - Uint64Array = 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 = Uint64Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Uint64Array, 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': new Uint64( 1 ) - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return add( v, v ); - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = 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 Uint64Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = 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 Uint64Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the method throws an error if provided an iterable object which returns values which cannot be converted to a 64-bit unsigned integers', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - 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 Uint64Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.5 - }; - } - - function next2() { - return { - 'value': -1 - }; - } -}); - -tape( 'the method throws an error if provided a 64-bit unsigned integer source array and a "map" function which does not return 64-bit unsigned integer', function test( t ) { - var values; - var clbks; - var i; - - values = [ - [ new Uint64( 1 ) ], - [ new Uint64( 1 ), new Uint64( 1 ) ] - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Uint64Array.from( value, clbk ); - }; - } - - function clbk1() { - return NaN; - } - - function clbk2() { - return {}; - } -}); - -tape( 'the method throws an error if provided a "map" function which returns values which cannot be converted to a 64-bit unsigned integers (iterable)', function test( t ) { - var Uint64Array; - var values; - var clbks; - var i; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Uint64Array.from( value, clbk ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1 - }; - } - - function clbk1() { - return {}; - } - - function next2() { - return { - 'value': new Uint64( 1 ) - }; - } - - function clbk2() { - return '1.0'; - } -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 8be2572..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isEqual = require( '@stdlib/number-uint64-base-assert-is-equal' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, '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( Uint64Array.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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 Uint64Array( 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 Uint64Array( 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 expected; - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Uint64( i ) ); - } - arr = new Uint64Array( arr ); - - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - expected = new Uint64( i ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2e04877..0000000 --- a/test/test.js +++ /dev/null @@ -1,934 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint64Array = require( './../lib' ); - - -// VARIABLES // - -var HAS_BIGINTS = hasBigIntSupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Uint64Array( 0 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (no argument)', function test( t ) { - var arr = new Uint64Array(); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor(); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (length)', function test( t ) { - var arr = new Uint64Array( 10 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (array)', function test( t ) { - var arr = new Uint64Array( [] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (typed array)', function test( t ) { - var arr = new Uint64Array( new Uint32Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( new Uint32Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (unsigned integer typed array)', function test( t ) { - var arr = new Uint64Array( new Uint64Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (unsigned integer typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( new Uint64Array( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (iterable)', function test( t ) { - var Uint64Array; - var arr; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Uint64Array( createIterable() ); - t.strictEqual( arr instanceof Uint64Array, 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 64-bit unsigned integer 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 64-bit unsigned integer array (ArrayBuffer)', function test( t ) { - var arr = new Uint64Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Uint64Array( new ArrayBuffer( 16 ), 16 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( new ArrayBuffer( 16 ), 16 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Uint64Array( new ArrayBuffer( 16 ), 16, 0 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit unsigned integer array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Uint64Array; - - arr = ctor( new ArrayBuffer( 16 ), 16, 0 ); - t.strictEqual( arr instanceof Uint64Array, 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( Uint64Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Uint64Array.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Uint64Array, 'name' ), true, 'has property' ); - t.strictEqual( Uint64Array.name, 'Uint64Array', '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( Uint64Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Uint64Array.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - - arr = new Uint64Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, '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 Uint64Array( 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 Uint64Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 16 ); - v = arr.byteLength; - t.strictEqual( v, 112, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 128 ); - 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 Uint64Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 128 ); - v = arr.byteOffset; - t.strictEqual( v, 128, '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 Uint64Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Uint64Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Uint64Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( [ 1, 2, 3, 4 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing `Uint64` instances: - arr = new Uint64Array( [ new Uint64( 1 ) ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = new Uint64Array( new Uint32Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new Uint32Array( [ 1, 1 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // 64-bit unsigned typed array: - arr = new Uint64Array( new Uint64Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new Uint64Array( [ 1, 1 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = new Uint64Array( new Uint64Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new Uint64Array( [ 1, 1 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Uint64Array( new ArrayBuffer( 128 ), 64 ); - v = arr.length; - t.strictEqual( v, 8, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 128 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Uint64Array( new ArrayBuffer( 128 ), 64, 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 Uint64Array; - var iter1; - var iter2; - var iter3; - var arr; - var v; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - - arr = new Uint64Array( createIterable( iter1 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - - arr = new Uint64Array( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - - arr = new Uint64Array( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - if ( HAS_BIGINTS ) { - iter3 = { - 'next': next3, - 'i': 0, - 'N': 4 - }; - - arr = new Uint64Array( createIterable( iter3 ) ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter3.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 next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': new Uint64( 1 ) - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': 1 - }; - } - return { - 'done': true - }; - } - - function next3() { - iter3.i += 1; - if ( iter3.i <= iter3.N ) { - return { - 'value': BigInt( 1 ) - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 21, - 74, - 801 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Uint64Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = 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 Uint64Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = 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 Uint64Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if provided an iterable object which returns values which cannot be converted to a 64-bit unsigned integers', function test( t ) { - var Uint64Array; - var values; - var i; - - Uint64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - 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 Uint64Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.5 - }; - } - - function next2() { - return { - 'value': -1 - }; - } -}); - -tape( 'the constructor throws an error if provided an array containing values which cannot be converted to a 64-bit unsigned integers', function test( t ) { - var values; - var i; - - values = [ - [ 1.5 ], - [ -1 ], - [ NaN ], - [ {} ], - [ [] ], - [ 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 Uint64Array( value ); - }; - } -}); - -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 Uint64Array( 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 Uint64Array( 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 Uint64Array( 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 Uint64Array( new ArrayBuffer( 128 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 21, - 65, - 78, - 801 - ]; - 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 Uint64Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32, - 48, - 56, - 64, - 72, - 80, - 88, - 100 - ]; - 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 Uint64Array( new ArrayBuffer( 102 ), 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 = [ - 16, - 24, - 32, - 48 - ]; - 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 Uint64Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index f64663a..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 64-bit unsigned integer array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Uint64Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.of ), true, 'has method' ); - - arr = Uint64Array.of(); - t.strictEqual( arr instanceof Uint64Array, 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 Uint64Array.of.call( value, 1, 1 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - 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 Uint64Array.of.call( value, 1, 1 ); - }; - } -}); - -tape( 'the method returns a 64-bit unsigned integer array', function test( t ) { - var arr; - var u; - var v; - - // No arguments: - arr = Uint64Array.of(); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Integer arguments: - arr = Uint64Array.of( 1, 2, 3, 4 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // 64-bit unsigned integers: - u = new Uint64( 1 ); - arr = Uint64Array.of( u, u, u, u, u ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - u = new Uint64( 1 ); - arr = Uint64Array.of( u, 2, u, 4 ); - t.strictEqual( arr instanceof Uint64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 3ad2c9b..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,744 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var isEqual = require( '@stdlib/number-uint64-base-assert-is-equal' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint64 = require( '@stdlib/number-uint64-ctor' ); -var Uint64Array = require( './../lib' ); - - -// VARIABLES // - -var HAS_BIGINTS = hasBigIntSupport(); -var opts = { - 'skip': !HAS_BIGINTS -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint64Array, '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( Uint64Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Uint64Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a 64-bit unsigned integer array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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 a first argument which is not a nonnegative integer, nonnegative bigint, 64-bit unsigned integer, 64-bit unsigned integer array, or array-like object', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 10 ); - - values = [ - -1, - 1.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.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a nonnegative integer, nonnegative bigint, 64-bit unsigned integer, 64-bit unsigned integer array, or array-like object (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 10 ); - - values = [ - -1, - 1.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.set( 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 Uint64Array( 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( new Uint64.of( 1, 1 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (64-bit unsigned integer)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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( new Uint64( 1 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (nonnegative integer)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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( 1, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (nonnegative bigint)', opts, function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 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( BigInt( 1 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (64-bit unsigned integer array)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Uint64Array( 10 ); - arr2 = new Uint64Array( 10 ); - - 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 throws an error if provided an index argument which is out-of-bounds (array-like object containing 64-bit unsigned integers)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Uint64Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( new Uint64( i ) ); - } - - 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 throws an error if provided an index argument which is out-of-bounds (array-like object containing nonnegative integers)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Uint64Array( 4 ); - arr2 = [ 1, 2, 3, 4, 5 ]; - - 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 throws an error if provided an array-like object containing an invalid element', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 10 ); - - values = [ - [ -1 ], - [ 1.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.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided an array-like object containing an invalid element (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint64Array( 10 ); - - values = [ - [ -1 ], - [ 1.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.set( value, 0 ); - }; - } -}); - -tape( 'the method sets an array element (64-bit unsigned integer)', function test( t ) { - var expected; - var arr; - var v; - var u; - var i; - - arr = new Uint64Array( 10 ); - - v = arr.get( 0 ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - // No index argument: - u = new Uint64( 20 ); - expected = u; - arr.set( u ); - - v = arr.get( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - arr.set( new Uint64( 0 ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - - u = new Uint64( i ); - expected = u; - arr.set( u, i ); - - v = arr.get( i ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - } - t.end(); -}); - -tape( 'the method sets an array element (nonnegative integer)', function test( t ) { - var expected; - var arr; - var v; - var u; - var i; - - arr = new Uint64Array( 10 ); - - v = arr.get( 0 ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - // No index argument: - u = 20; - arr.set( u ); - - v = arr.get( 0 ); - expected = new Uint64( u ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - arr.set( 0 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - - arr.set( i, i ); - - v = arr.get( i ); - expected = new Uint64( i ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - } - t.end(); -}); - -tape( 'the method sets an array element (nonnegative bigint)', opts, function test( t ) { - var expected; - var arr; - var v; - var u; - var i; - - arr = new Uint64Array( 10 ); - - v = arr.get( 0 ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - // No index argument: - u = BigInt( 20 ); - arr.set( u ); - expected = new Uint64( u ); - - v = arr.get( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - arr.set( BigInt( 0 ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - - expected = new Uint64( i ); - arr.set( BigInt( i ), i ); - - v = arr.get( i ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - } - t.end(); -}); - -tape( 'the method sets an array element (array-like object containing 64-bit unsigned integers)', function test( t ) { - var expected1; - var expected2; - var expected; - var arr; - var u1; - var u2; - var v; - var u; - var i; - - arr = new Uint64Array( 10 ); - - v = arr.get( 0 ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - // No index argument: - u = new Uint64( 20 ); - expected = u; - arr.set( [ u ] ); - - v = arr.get( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - arr.set( [ new Uint64( 0 ) ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - expected = new Uint64( 0 ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - - u = new Uint64( i ); - expected = u; - arr.set( [ u ], i ); - - v = arr.get( i ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+i ); - } - - // Multiple values, no index argument: - u1 = new Uint64( 10 ); - u2 = new Uint64( 40 ); - - arr.set( [ u1, u2 ] ); - - v = arr.get( 0 ); - expected1 = u1; - t.strictEqual( isEqual( v, expected1 ), true, 'returns expected value for index '+0 ); - - v = arr.get( 1 ); - expected2 = u2; - t.strictEqual( isEqual( v, expected2 ), true, 'returns expected value for index '+1 ); - - // Multiple values, index argument: - u1 = new Uint64( 100 ); - u2 = new Uint64( 300 ); - - arr.set( [ u1, u2 ], 2 ); - - v = arr.get( 2 ); - expected1 = u1; - t.strictEqual( isEqual( v, expected1 ), true, 'returns expected value for index '+2 ); - - v = arr.get( 3 ); - expected2 = u2; - t.strictEqual( isEqual( v, expected2 ), true, 'returns expected value for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (typed array; shared buffer)', function test( t ) { - var byteOffset; - var expected; - var arr; - var src; - var buf; - var ab; - var v; - - byteOffset = 224; - - ab = new ArrayBuffer( 480 ); - arr = new Uint64Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20, 30 ]; - src = new Float64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 1 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ 100, 200 ]; - src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+2 ); - - v = arr.get( 3 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25, 45 ]; - src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 1 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ 105, 205 ]; - src = new Float64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+2 ); - - v = arr.get( 3 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (64-bit unsigned integer typed array; shared buffer)', function test( t ) { - var byteOffset; - var expected; - var arr; - var src; - var buf; - var ab; - var v; - - byteOffset = 224; - - ab = new ArrayBuffer( 480 ); - arr = new Uint64Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20, 30 ]; - src = new Uint64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 1 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ 100, 200, 300, 400 ]; - src = new Uint64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 3 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - v = arr.get( 4 ); - expected = new Uint64( buf[ 2 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+2 ); - - v = arr.get( 5 ); - expected = new Uint64( buf[ 3 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+3 ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25, 35, 45, 55 ]; - src = new Uint64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 1 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ 105, 205, 305, 405 ]; - src = new Uint64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 4 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - expected = new Uint64( buf[ 0 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+0 ); - - v = arr.get( 3 ); - expected = new Uint64( buf[ 1 ] ); - t.strictEqual( isEqual( v, expected ), true, 'returns expected value for index '+1 ); - - t.end(); -});