From ecba7e2d0437ef5def3e5dbcaaa95eb3680abdf6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 25 Sep 2024 08:04:53 +0000 Subject: [PATCH 01/14] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 478616c..e55f89e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var inherits = require( '@stdlib/utils-inherit' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var fromIterator = require( './from_iterator.js' ); var fromIteratorMap = require( './from_iterator_map.js' ); @@ -255,7 +255,7 @@ function factory( dtype ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); @@ -264,7 +264,7 @@ function factory( dtype ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -290,7 +290,7 @@ function factory( dtype ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { 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 ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -305,7 +305,7 @@ function factory( dtype ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -324,7 +324,7 @@ function factory( dtype ) { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); diff --git a/package.json b/package.json index 20151c1..965c8eb 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-object": "^0.2.2", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", From a63e9faa1d4dd86f72846d4f99cf9c5b1e678941 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 25 Sep 2024 08:05:48 +0000 Subject: [PATCH 02/14] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.from.js | 311 -- benchmark/benchmark.get.js | 62 - benchmark/benchmark.instantiation.js | 253 -- benchmark/benchmark.js | 48 - benchmark/benchmark.of.js | 74 - benchmark/benchmark.property_access.js | 127 - benchmark/benchmark.set.js | 124 - benchmark/benchmark.set.length.js | 115 - benchmark/benchmark.to_string.js | 55 - benchmark/benchmark.to_string.length.js | 99 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 44 - index.mjs | 4 + index.mjs.map | 1 + lib/from_iterator.js | 48 - lib/from_iterator_map.js | 53 - lib/index.js | 106 - lib/main.js | 359 -- package.json | 73 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 49 files changed, 4870 insertions(+), 5358 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.instantiation.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.property_access.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/from_iterator.js delete mode 100644 lib/from_iterator_map.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f79cdfb..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/little-endian-factory) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 65c8f87..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/little-endian-factory) 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 58a2043..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: '23 23 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -523,7 +514,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]. @@ -586,13 +577,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-little-endian-factory/main/LICENSE -[@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/wasm/memory]: https://github.com/stdlib-js/wasm-memory +[@stdlib/wasm/memory]: https://github.com/stdlib-js/wasm-memory/tree/esm -[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 86f84c5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 53ca74b..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.instantiation.js b/benchmark/benchmark.instantiation.js deleted file mode 100644 index dec39fe..0000000 --- a/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - 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 Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a8bfba3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 1dec0ac..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.property_access.js b/benchmark/benchmark.property_access.js deleted file mode 100644 index 9be0011..0000000 --- a/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index c98a89d..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 61df165..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randu = require( '@stdlib/random-array-randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 2084462..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3f8cfe1..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8aa32b0..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/little-endian-factory" -%% click B href "https://github.com/stdlib-js/array-little-endian-factory/tree/main" -%% click C href "https://github.com/stdlib-js/array-little-endian-factory/tree/production" -%% click D href "https://github.com/stdlib-js/array-little-endian-factory/tree/esm" -%% click E href "https://github.com/stdlib-js/array-little-endian-factory/tree/deno" -%% click F href "https://github.com/stdlib-js/array-little-endian-factory/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/little-endian-factory -[production-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/production -[deno-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 162e128..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var R=q(function(W,d){"use strict";function M(a){var e,u;for(e=[];u=a.next(),!u.done;)e.push(u.value);return e}d.exports=M});var x=q(function(X,_){"use strict";function F(a,e,u){var l,s,r;for(l=[],r=-1;s=a.next(),!s.done;)r+=1,l.push(e.call(u,s.value,r));return l}_.exports=F});var O=q(function(Z,S){"use strict";var L=require("@stdlib/assert-is-collection"),Y=require("@stdlib/assert-is-object"),g=require("@stdlib/assert-is-function"),k=require("@stdlib/assert-has-iterator-symbol-support"),A=require("@stdlib/symbol-iterator"),w=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/array-base-getter"),C=require("@stdlib/array-base-accessor-getter"),P=require("@stdlib/utils-inherit"),j=require("@stdlib/array-fixed-endian-factory"),N=require("@stdlib/ndarray-base-bytes-per-element"),V=require("@stdlib/string-base-capitalize"),c=require("@stdlib/string-format"),D=R(),H=x(),U=k(),T="little-endian",z={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},I={c:"a",f:"a",i:"an",u:"a",b:"a"};function G(a){return V(a)+"ArrayLE"}function J(a){var e,u,l,s;s=j(a),e=N(a),u=G(a),l=z[a];function r(){var n=arguments.length;return this instanceof r?(n===0?s.call(this,T):n===1?s.call(this,T,arguments[0]):n===2?s.call(this,T,arguments[0],arguments[1]):n===3&&s.call(this,T,arguments[0],arguments[1],arguments[2]),this):n===0?new r:n===1?new r(arguments[0]):n===2?new r(arguments[0],arguments[1]):new r(arguments[0],arguments[1],arguments[2])}return w(r,"BYTES_PER_ELEMENT",e),w(r,"name",u),w(r,"from",function(t){var o,b,v,m,f,E,p,h,i;if(!g(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!y(this))throw new TypeError(c("invalid invocation. `this` is not %s %s.",I[a[0]],u));if(b=arguments.length,b>1){if(v=arguments[1],!g(v))throw new TypeError(c("invalid argument. Second argument must be a function. Value: `%s`.",v));b>2&&(o=arguments[2])}if(L(t)){if(v){for(h=t.length,t.get&&t.set?p=C("default"):p=B("default"),m=new this(h),f=m._buffer,i=0;i\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\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\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @module @stdlib/array-little-endian-factory\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_main", "__commonJSMin", "exports", "module", "isCollection", "isObject", "isFunction", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "getter", "accessorGetter", "inherits", "fixedEndianFactory", "bytesPerElement", "capitalize", "format", "fromIterator", "fromIteratorMap", "HAS_ITERATOR_SYMBOL", "BYTE_ORDER", "DTYPE2SET", "CHAR2ARTICLE", "dtype2ctor", "dtype", "factory", "BYTES_PER_ELEMENT", "CTOR_NAME", "SETTER", "parent", "TypedArray", "nargs", "src", "thisArg", "clbk", "out", "buf", "tmp", "get", "len", "isTypedArrayConstructor", "args", "i", "value", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3b2058f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var logEach = require( '@stdlib/console-log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aa4efde --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index c1adb5d..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c95efa..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array-little-endian-factory -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e55f89e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var getter = require( '@stdlib/array-base-getter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var inherits = require( '@stdlib/utils-inherit' ); -var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/package.json b/package.json index 965c8eb..f8559db 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", "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,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-fixed-endian-factory": "github:stdlib-js/array-fixed-endian-factory#main", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-zero-to": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/console-log-each": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..29bb616 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 99d011d..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests From 30eb588e28e0a095b65e838d3eb60e496b45fe4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:01:41 +0000 Subject: [PATCH 03/14] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 478616c..e55f89e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var inherits = require( '@stdlib/utils-inherit' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var fromIterator = require( './from_iterator.js' ); var fromIteratorMap = require( './from_iterator_map.js' ); @@ -255,7 +255,7 @@ function factory( dtype ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); @@ -264,7 +264,7 @@ function factory( dtype ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -290,7 +290,7 @@ function factory( dtype ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { 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 ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -305,7 +305,7 @@ function factory( dtype ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -324,7 +324,7 @@ function factory( dtype ) { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); diff --git a/package.json b/package.json index d082868..c767e8d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-object": "^0.2.2", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", From f0434faace19b4d81d2625f1ebc768d53c3562f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:02:07 +0000 Subject: [PATCH 04/14] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aa4efde..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29bb616..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 704fd65260492830c9f378350afcbce312de844e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:02:28 +0000 Subject: [PATCH 05/14] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.from.js | 311 -- benchmark/benchmark.get.js | 62 - benchmark/benchmark.instantiation.js | 253 -- benchmark/benchmark.js | 48 - benchmark/benchmark.of.js | 74 - benchmark/benchmark.property_access.js | 127 - benchmark/benchmark.set.js | 124 - benchmark/benchmark.set.length.js | 115 - benchmark/benchmark.to_string.js | 55 - benchmark/benchmark.to_string.length.js | 99 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 44 - index.mjs | 4 + index.mjs.map | 1 + lib/from_iterator.js | 48 - lib/from_iterator_map.js | 53 - lib/index.js | 106 - lib/main.js | 359 -- package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 49 files changed, 4870 insertions(+), 5358 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.instantiation.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.property_access.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/from_iterator.js delete mode 100644 lib/from_iterator_map.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f79cdfb..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/little-endian-factory) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 65c8f87..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/little-endian-factory) 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 58a2043..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: '23 23 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -523,7 +514,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]. @@ -586,13 +577,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-little-endian-factory/main/LICENSE -[@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/wasm/memory]: https://github.com/stdlib-js/wasm-memory +[@stdlib/wasm/memory]: https://github.com/stdlib-js/wasm-memory/tree/esm -[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 86f84c5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 53ca74b..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.instantiation.js b/benchmark/benchmark.instantiation.js deleted file mode 100644 index dec39fe..0000000 --- a/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - 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 Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a8bfba3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 1dec0ac..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.property_access.js b/benchmark/benchmark.property_access.js deleted file mode 100644 index 9be0011..0000000 --- a/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index c98a89d..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 61df165..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randu = require( '@stdlib/random-array-randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 2084462..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3f8cfe1..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8aa32b0..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/little-endian-factory" -%% click B href "https://github.com/stdlib-js/array-little-endian-factory/tree/main" -%% click C href "https://github.com/stdlib-js/array-little-endian-factory/tree/production" -%% click D href "https://github.com/stdlib-js/array-little-endian-factory/tree/esm" -%% click E href "https://github.com/stdlib-js/array-little-endian-factory/tree/deno" -%% click F href "https://github.com/stdlib-js/array-little-endian-factory/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/little-endian-factory -[production-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/production -[deno-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 162e128..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var R=q(function(W,d){"use strict";function M(a){var e,u;for(e=[];u=a.next(),!u.done;)e.push(u.value);return e}d.exports=M});var x=q(function(X,_){"use strict";function F(a,e,u){var l,s,r;for(l=[],r=-1;s=a.next(),!s.done;)r+=1,l.push(e.call(u,s.value,r));return l}_.exports=F});var O=q(function(Z,S){"use strict";var L=require("@stdlib/assert-is-collection"),Y=require("@stdlib/assert-is-object"),g=require("@stdlib/assert-is-function"),k=require("@stdlib/assert-has-iterator-symbol-support"),A=require("@stdlib/symbol-iterator"),w=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/array-base-getter"),C=require("@stdlib/array-base-accessor-getter"),P=require("@stdlib/utils-inherit"),j=require("@stdlib/array-fixed-endian-factory"),N=require("@stdlib/ndarray-base-bytes-per-element"),V=require("@stdlib/string-base-capitalize"),c=require("@stdlib/string-format"),D=R(),H=x(),U=k(),T="little-endian",z={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},I={c:"a",f:"a",i:"an",u:"a",b:"a"};function G(a){return V(a)+"ArrayLE"}function J(a){var e,u,l,s;s=j(a),e=N(a),u=G(a),l=z[a];function r(){var n=arguments.length;return this instanceof r?(n===0?s.call(this,T):n===1?s.call(this,T,arguments[0]):n===2?s.call(this,T,arguments[0],arguments[1]):n===3&&s.call(this,T,arguments[0],arguments[1],arguments[2]),this):n===0?new r:n===1?new r(arguments[0]):n===2?new r(arguments[0],arguments[1]):new r(arguments[0],arguments[1],arguments[2])}return w(r,"BYTES_PER_ELEMENT",e),w(r,"name",u),w(r,"from",function(t){var o,b,v,m,f,E,p,h,i;if(!g(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!y(this))throw new TypeError(c("invalid invocation. `this` is not %s %s.",I[a[0]],u));if(b=arguments.length,b>1){if(v=arguments[1],!g(v))throw new TypeError(c("invalid argument. Second argument must be a function. Value: `%s`.",v));b>2&&(o=arguments[2])}if(L(t)){if(v){for(h=t.length,t.get&&t.set?p=C("default"):p=B("default"),m=new this(h),f=m._buffer,i=0;i\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\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\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @module @stdlib/array-little-endian-factory\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA6BA,SAASC,EAAcC,EAAK,CAC3B,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIF,EAAG,KAAK,EACP,CAAAE,EAAE,MAGPD,EAAI,KAAMC,EAAE,KAAM,EAEnB,OAAOD,CACR,CAKAH,EAAO,QAAUC,IC/CjB,IAAAI,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA+BA,SAASC,EAAiBC,EAAIC,EAAMC,EAAU,CAC7C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAM,CAAC,EACPE,EAAI,GAEHD,EAAIJ,EAAG,KAAK,EACP,CAAAI,EAAE,MAGPC,GAAK,EACLF,EAAI,KAAMF,EAAK,KAAMC,EAASE,EAAE,MAAOC,CAAE,CAAE,EAE5C,OAAOF,CACR,CAKAL,EAAO,QAAUC,ICpDjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAe,QAAS,8BAA+B,EACvDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAa,QAAS,4BAA6B,EACnDC,EAA2B,QAAS,4CAA6C,EACjFC,EAAkB,QAAS,yBAA0B,EACrDC,EAAc,QAAS,uDAAwD,EAC/EC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAW,QAAS,uBAAwB,EAC5CC,EAAqB,QAAS,oCAAqC,EACnEC,EAAkB,QAAS,wCAAyC,EACpEC,EAAa,QAAS,gCAAiC,EACvDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAe,IACfC,EAAkB,IAKlBC,EAAsBZ,EAAyB,EAC/Ca,EAAa,gBACbC,EAAY,CACf,QAAW,aACX,QAAW,aACX,MAAS,WACT,MAAS,WACT,OAAU,YACV,OAAU,WACX,EACIC,EAAe,CAClB,EAAK,IACL,EAAK,IACL,EAAK,KACL,EAAK,IACL,EAAK,GACN,EAoBA,SAASC,EAAYC,EAAQ,CAC5B,OAAOT,EAAYS,CAAM,EAAI,SAC9B,CA2EA,SAASC,EAASD,EAAQ,CACzB,IAAIE,EACAC,EACAC,EACAC,EAGJA,EAAShB,EAAoBW,CAAM,EAEnCE,EAAoBZ,EAAiBU,CAAM,EAC3CG,EAAYJ,EAAYC,CAAM,EAC9BI,EAASP,EAAWG,CAAM,EAe1B,SAASM,GAAa,CACrB,IAAIC,EAAQ,UAAU,OACtB,OAAO,gBAAgBD,GAYlBC,IAAU,EACdF,EAAO,KAAM,KAAMT,CAAW,EACnBW,IAAU,EACrBF,EAAO,KAAM,KAAMT,EAAY,UAAU,CAAC,CAAE,EACjCW,IAAU,EACrBF,EAAO,KAAM,KAAMT,EAAY,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAC/CW,IAAU,GACrBF,EAAO,KAAM,KAAMT,EAAY,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAElE,MApBDW,IAAU,EACP,IAAID,EAEPC,IAAU,EACP,IAAID,EAAY,UAAU,CAAC,CAAE,EAEhCC,IAAU,EACP,IAAID,EAAY,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAE5C,IAAIA,EAAY,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,CAYlE,CAWA,OAAArB,EAAaqB,EAAY,oBAAqBJ,CAAkB,EAWhEjB,EAAaqB,EAAY,OAAQH,CAAU,EAkB3ClB,EAAaqB,EAAY,OAAQ,SAAeE,EAAM,CACrD,IAAIC,EACAF,EACAG,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EACJ,GAAK,CAACjC,EAAY,IAAK,EACtB,MAAM,IAAI,UAAW,2DAA4D,EAElF,GAAK,CAACkC,EAAyB,IAAK,EACnC,MAAM,IAAI,UAAWxB,EAAQ,2CAA4CM,EAAcE,EAAM,CAAC,CAAE,EAAGG,CAAU,CAAE,EAGhH,GADAI,EAAQ,UAAU,OACbA,EAAQ,EAAI,CAEhB,GADAG,EAAO,UAAW,CAAE,EACf,CAAC5B,EAAY4B,CAAK,EACtB,MAAM,IAAI,UAAWlB,EAAQ,qEAAsEkB,CAAK,CAAE,EAEtGH,EAAQ,IACZE,EAAU,UAAW,CAAE,EAEzB,CACA,GAAK7B,EAAc4B,CAAI,EAAI,CAC1B,GAAKE,EAAO,CASX,IARAK,EAAMP,EAAI,OACLA,EAAI,KAAOA,EAAI,IACnBM,EAAM3B,EAAgB,SAAU,EAEhC2B,EAAM5B,EAAQ,SAAU,EAEzByB,EAAM,IAAI,KAAMI,CAAI,EACpBH,EAAMD,EAAI,QACJ,EAAI,EAAG,EAAII,EAAK,IACrBH,EAAKR,CAAO,EAAG,EAAEF,EAAmBQ,EAAK,KAAMD,EAASK,EAAKN,EAAK,CAAE,EAAG,CAAE,EAAG,EAAK,EAElF,OAAOG,CACR,CACA,OAAO,IAAI,KAAMH,CAAI,CACtB,CACA,GAAK3B,EAAU2B,CAAI,GAAKb,GAAuBb,EAAY0B,EAAKxB,CAAgB,CAAE,EAAI,CAErF,GADA4B,EAAMJ,EAAKxB,CAAgB,EAAE,EACxB,CAACF,EAAY8B,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWpB,EAAQ,6FAA8FgB,CAAI,CAAE,EAUlI,IARKE,EACJG,EAAMnB,EAAiBkB,EAAKF,EAAMD,CAAQ,EAE1CI,EAAMpB,EAAcmB,CAAI,EAEzBG,EAAMF,EAAI,OACVF,EAAM,IAAI,KAAMI,CAAI,EACpBH,EAAMD,EAAI,QACJ,EAAI,EAAG,EAAII,EAAK,IACrBH,EAAKR,CAAO,EAAG,EAAEF,EAAmBW,EAAK,CAAE,EAAG,EAAK,EAEpD,OAAOF,CACR,CACA,MAAM,IAAI,UAAWnB,EAAQ,6FAA8FgB,CAAI,CAAE,CAClI,CAAC,EAcDvB,EAAaqB,EAAY,KAAM,UAAc,CAC5C,IAAIW,EACAC,EACJ,GAAK,CAACpC,EAAY,IAAK,EACtB,MAAM,IAAI,UAAW,2DAA4D,EAElF,GAAK,CAACkC,EAAyB,IAAK,EACnC,MAAM,IAAI,UAAWxB,EAAQ,2CAA4CM,EAAcE,EAAM,CAAC,CAAE,EAAGG,CAAU,CAAE,EAGhH,IADAc,EAAO,CAAC,EACFC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCD,EAAK,KAAM,UAAWC,CAAE,CAAE,EAE3B,OAAO,IAAI,KAAMD,CAAK,CACvB,CAAC,EAGD7B,EAAUkB,EAAYD,CAAO,EAEtBC,EASP,SAASU,EAAyBG,EAAQ,CACzC,OAASA,IAAUb,CACpB,CACD,CAKA3B,EAAO,QAAUsB,IClQjB,IAAImB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_main", "__commonJSMin", "exports", "module", "isCollection", "isObject", "isFunction", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "getter", "accessorGetter", "inherits", "fixedEndianFactory", "bytesPerElement", "capitalize", "format", "fromIterator", "fromIteratorMap", "HAS_ITERATOR_SYMBOL", "BYTE_ORDER", "DTYPE2SET", "CHAR2ARTICLE", "dtype2ctor", "dtype", "factory", "BYTES_PER_ELEMENT", "CTOR_NAME", "SETTER", "parent", "TypedArray", "nargs", "src", "thisArg", "clbk", "out", "buf", "tmp", "get", "len", "isTypedArrayConstructor", "args", "i", "value", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3b2058f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var logEach = require( '@stdlib/console-log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aa4efde --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index c1adb5d..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c95efa..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array-little-endian-factory -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e55f89e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var getter = require( '@stdlib/array-base-getter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var inherits = require( '@stdlib/utils-inherit' ); -var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/package.json b/package.json index c767e8d..f8559db 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", "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", - "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", @@ -35,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-fixed-endian-factory": "github:stdlib-js/array-fixed-endian-factory#main", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-zero-to": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/console-log-each": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..29bb616 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 99d011d..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests From b83f4b3464ed67cf6f6bdd61adadb5692c8eed33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:51:35 +0000 Subject: [PATCH 06/14] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 478616c..e55f89e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var inherits = require( '@stdlib/utils-inherit' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var fromIterator = require( './from_iterator.js' ); var fromIteratorMap = require( './from_iterator_map.js' ); @@ -255,7 +255,7 @@ function factory( dtype ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); @@ -264,7 +264,7 @@ function factory( dtype ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -290,7 +290,7 @@ function factory( dtype ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { 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 ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -305,7 +305,7 @@ function factory( dtype ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -324,7 +324,7 @@ function factory( dtype ) { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); diff --git a/package.json b/package.json index d082868..c767e8d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-object": "^0.2.2", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", From eedf1aee090f1f8e60e01ab953c040b816ce478f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 05:07:51 +0000 Subject: [PATCH 07/14] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aa4efde..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29bb616..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a74d877a4f30eea2821376c89b8b0d5be814cb6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 05:08:11 +0000 Subject: [PATCH 08/14] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.from.js | 311 -- benchmark/benchmark.get.js | 62 - benchmark/benchmark.instantiation.js | 253 - benchmark/benchmark.js | 48 - benchmark/benchmark.of.js | 74 - benchmark/benchmark.property_access.js | 127 - benchmark/benchmark.set.js | 124 - benchmark/benchmark.set.length.js | 115 - benchmark/benchmark.to_string.js | 55 - benchmark/benchmark.to_string.length.js | 99 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 44 - index.mjs | 4 + index.mjs.map | 1 + lib/from_iterator.js | 48 - lib/from_iterator_map.js | 53 - lib/index.js | 106 - lib/main.js | 359 -- package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 51 files changed, 4870 insertions(+), 5464 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.instantiation.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.property_access.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/from_iterator.js delete mode 100644 lib/from_iterator_map.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ab370b0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T03:17:17.240Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f79cdfb..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/little-endian-factory) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 65c8f87..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/little-endian-factory) 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 58a2043..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: '23 23 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -523,7 +514,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]. @@ -586,13 +577,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-little-endian-factory/main/LICENSE -[@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/wasm/memory]: https://github.com/stdlib-js/wasm-memory +[@stdlib/wasm/memory]: https://github.com/stdlib-js/wasm-memory/tree/esm -[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 86f84c5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 53ca74b..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.instantiation.js b/benchmark/benchmark.instantiation.js deleted file mode 100644 index dec39fe..0000000 --- a/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - 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 Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a8bfba3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 1dec0ac..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.property_access.js b/benchmark/benchmark.property_access.js deleted file mode 100644 index 9be0011..0000000 --- a/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index c98a89d..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 61df165..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randu = require( '@stdlib/random-array-randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 2084462..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3f8cfe1..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8aa32b0..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/little-endian-factory" -%% click B href "https://github.com/stdlib-js/array-little-endian-factory/tree/main" -%% click C href "https://github.com/stdlib-js/array-little-endian-factory/tree/production" -%% click D href "https://github.com/stdlib-js/array-little-endian-factory/tree/esm" -%% click E href "https://github.com/stdlib-js/array-little-endian-factory/tree/deno" -%% click F href "https://github.com/stdlib-js/array-little-endian-factory/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/little-endian-factory -[production-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/production -[deno-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 162e128..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var R=q(function(W,d){"use strict";function M(a){var e,u;for(e=[];u=a.next(),!u.done;)e.push(u.value);return e}d.exports=M});var x=q(function(X,_){"use strict";function F(a,e,u){var l,s,r;for(l=[],r=-1;s=a.next(),!s.done;)r+=1,l.push(e.call(u,s.value,r));return l}_.exports=F});var O=q(function(Z,S){"use strict";var L=require("@stdlib/assert-is-collection"),Y=require("@stdlib/assert-is-object"),g=require("@stdlib/assert-is-function"),k=require("@stdlib/assert-has-iterator-symbol-support"),A=require("@stdlib/symbol-iterator"),w=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/array-base-getter"),C=require("@stdlib/array-base-accessor-getter"),P=require("@stdlib/utils-inherit"),j=require("@stdlib/array-fixed-endian-factory"),N=require("@stdlib/ndarray-base-bytes-per-element"),V=require("@stdlib/string-base-capitalize"),c=require("@stdlib/string-format"),D=R(),H=x(),U=k(),T="little-endian",z={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},I={c:"a",f:"a",i:"an",u:"a",b:"a"};function G(a){return V(a)+"ArrayLE"}function J(a){var e,u,l,s;s=j(a),e=N(a),u=G(a),l=z[a];function r(){var n=arguments.length;return this instanceof r?(n===0?s.call(this,T):n===1?s.call(this,T,arguments[0]):n===2?s.call(this,T,arguments[0],arguments[1]):n===3&&s.call(this,T,arguments[0],arguments[1],arguments[2]),this):n===0?new r:n===1?new r(arguments[0]):n===2?new r(arguments[0],arguments[1]):new r(arguments[0],arguments[1],arguments[2])}return w(r,"BYTES_PER_ELEMENT",e),w(r,"name",u),w(r,"from",function(t){var o,b,v,m,f,E,p,h,i;if(!g(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!y(this))throw new TypeError(c("invalid invocation. `this` is not %s %s.",I[a[0]],u));if(b=arguments.length,b>1){if(v=arguments[1],!g(v))throw new TypeError(c("invalid argument. Second argument must be a function. Value: `%s`.",v));b>2&&(o=arguments[2])}if(L(t)){if(v){for(h=t.length,t.get&&t.set?p=C("default"):p=B("default"),m=new this(h),f=m._buffer,i=0;i\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\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\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @module @stdlib/array-little-endian-factory\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_main", "__commonJSMin", "exports", "module", "isCollection", "isObject", "isFunction", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "getter", "accessorGetter", "inherits", "fixedEndianFactory", "bytesPerElement", "capitalize", "format", "fromIterator", "fromIteratorMap", "HAS_ITERATOR_SYMBOL", "BYTE_ORDER", "DTYPE2SET", "CHAR2ARTICLE", "dtype2ctor", "dtype", "factory", "BYTES_PER_ELEMENT", "CTOR_NAME", "SETTER", "parent", "TypedArray", "nargs", "src", "thisArg", "clbk", "out", "buf", "tmp", "get", "len", "isTypedArrayConstructor", "args", "i", "value", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3b2058f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var logEach = require( '@stdlib/console-log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aa4efde --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":";;wvCA2CA,IAAIA,EAAsBC,IACtBC,EAAa,gBACbC,EAAY,CACfC,QAAW,aACXC,QAAW,aACXC,MAAS,WACTC,MAAS,WACTC,OAAU,YACVC,OAAU,aAEPC,EAAe,CAClBC,EAAK,IACLC,EAAK,IACLC,EAAK,KACLC,EAAK,IACLC,EAAK,KAkGN,SAASC,EAASC,GACjB,IAAIC,EACAC,EACAC,EACAC,EAsBJ,SAASC,IACR,IAAIC,EAAQC,UAAUC,OACtB,OAAOC,gBAAgBJ,GAYR,IAAVC,EACJF,EAAOM,KAAMD,KAAMxB,GACE,IAAVqB,EACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,IACpB,IAAVD,EACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,GAAIA,UAAU,IAClC,IAAVD,GACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAE/DE,MApBS,IAAVH,EACG,IAAID,EAEG,IAAVC,EACG,IAAID,EAAYE,UAAU,IAEnB,IAAVD,EACG,IAAID,EAAYE,UAAU,GAAIA,UAAU,IAEzC,IAAIF,EAAYE,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAY9D,CAuID,OAlLAH,EAASO,EAAoBX,GAE7BC,EAAoBW,EAAiBZ,GACrCE,EAvFD,SAAqBF,GACpB,OAAOa,EAAYb,GAAU,SAC9B,CAqFac,CAAYd,GACxBG,EAASjB,EAAWc,GAkDpBe,EAAaV,EAAY,oBAAqBJ,GAW9Cc,EAAaV,EAAY,OAAQH,GAkBjCa,EAAaV,EAAY,QAAQ,SAAeW,GAC/C,IAAIC,EACAX,EACAY,EACAC,EACAC,EACAC,EACAC,EACAC,EACA3B,EACJ,IAAM4B,EAAYf,MACjB,MAAM,IAAIgB,UAAWC,EAAO,WAE7B,IAAMC,EAAyBlB,MAC9B,MAAM,IAAIgB,UAAWC,EAAQ,2CAA4CjC,EAAcO,EAAM,IAAME,IAGpG,IADAI,EAAQC,UAAUC,QACL,EAAI,CAEhB,IAAMgB,EADNN,EAAOX,UAAW,IAEjB,MAAM,IAAIkB,UAAWC,EAAQ,SAAUR,IAEnCZ,EAAQ,IACZW,EAAUV,UAAW,GAEtB,CACD,GAAKqB,EAAcZ,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARAK,EAAMP,EAAIR,OAETc,EADIN,EAAIM,KAAON,EAAIa,IACbC,EAAgB,WAEhBC,EAAQ,WAGfX,GADAD,EAAM,IAAIV,KAAMc,IACNS,QACJpC,EAAI,EAAGA,EAAI2B,EAAK3B,IACrBwB,EAAKjB,GAAUP,EAAEK,EAAmBiB,EAAKR,KAAMO,EAASK,EAAKN,EAAKpB,GAAKA,IAAK,GAE7E,OAAOuB,CACP,CACD,OAAO,IAAIV,KAAMO,EACjB,CACD,GAAKiB,EAAUjB,IAASjC,GAAuByC,EAAYR,EAAKkB,IAAsB,CAErF,GADAd,EAAMJ,EAAKkB,MACLV,EAAYJ,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,SAAUV,IAUxC,IAPCK,EADIH,ECvQR,SAA0BkB,EAAIlB,EAAMD,GACnC,IAAIE,EACAkB,EACAzC,EAIJ,IAFAuB,EAAM,GACNvB,GAAK,IAEJyC,EAAID,EAAGD,QACAG,MAGP1C,GAAK,EACLuB,EAAIoB,KAAMrB,EAAKR,KAAMO,EAASoB,EAAEG,MAAO5C,IAExC,OAAOuB,CACR,CDwPUsB,CAAiBrB,EAAKF,EAAMD,GE1QtC,SAAuBmB,GACtB,IAAIjB,EACAkB,EAGJ,IADAlB,EAAM,KAELkB,EAAID,EAAGD,QACAG,MAGPnB,EAAIoB,KAAMF,EAAEG,OAEb,OAAOrB,CACR,CF+PUuB,CAActB,GAIrBA,GADAD,EAAM,IAAIV,KADVc,EAAMF,EAAIb,SAEAwB,QACJpC,EAAI,EAAGA,EAAI2B,EAAK3B,IACrBwB,EAAKjB,GAAUP,EAAEK,EAAmBoB,EAAKzB,IAAK,GAE/C,OAAOuB,CACP,CACD,MAAM,IAAIM,UAAWC,EAAQ,SAAUV,GACzC,IAcCD,EAAaV,EAAY,MAAM,WAC9B,IAAIsC,EACA/C,EACJ,IAAM4B,EAAYf,MACjB,MAAM,IAAIgB,UAAWC,EAAO,WAE7B,IAAMC,EAAyBlB,MAC9B,MAAM,IAAIgB,UAAWC,EAAQ,2CAA4CjC,EAAcO,EAAM,IAAME,IAGpG,IADAyC,EAAO,GACD/C,EAAI,EAAGA,EAAIW,UAAUC,OAAQZ,IAClC+C,EAAKJ,KAAMhC,UAAWX,IAEvB,OAAO,IAAIa,KAAMkC,EACnB,IAGCC,EAAUvC,EAAYD,GAEfC,EASP,SAASsB,EAAyBa,GACjC,OAASA,IAAUnC,CACnB,CACF"} \ No newline at end of file diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index c1adb5d..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c95efa..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array-little-endian-factory -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e55f89e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var getter = require( '@stdlib/array-base-getter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var inherits = require( '@stdlib/utils-inherit' ); -var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/package.json b/package.json index c767e8d..f8559db 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", "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", - "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", @@ -35,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-fixed-endian-factory": "github:stdlib-js/array-fixed-endian-factory#main", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-zero-to": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/console-log-each": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..29bb616 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 99d011d..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests From c8d30ae381e50935fc9efd5e19e9d6f46905e3b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:12:24 +0000 Subject: [PATCH 09/14] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 478616c..e55f89e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var inherits = require( '@stdlib/utils-inherit' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var fromIterator = require( './from_iterator.js' ); var fromIteratorMap = require( './from_iterator_map.js' ); @@ -255,7 +255,7 @@ function factory( dtype ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); @@ -264,7 +264,7 @@ function factory( dtype ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -290,7 +290,7 @@ function factory( dtype ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { 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 ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -305,7 +305,7 @@ function factory( dtype ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -324,7 +324,7 @@ function factory( dtype ) { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); diff --git a/package.json b/package.json index d082868..c767e8d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-object": "^0.2.2", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", From 1bef4641e959b37cd7bc2516ccc9d4b5b61c6894 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:44:28 +0000 Subject: [PATCH 10/14] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aa4efde..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29bb616..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 92595f29dc11b25883ead11cf3b2ecb477b9160e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 17 Mar 2025 02:44:53 +0000 Subject: [PATCH 11/14] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.from.js | 311 -- benchmark/benchmark.get.js | 62 - benchmark/benchmark.instantiation.js | 253 - benchmark/benchmark.js | 48 - benchmark/benchmark.of.js | 74 - benchmark/benchmark.property_access.js | 127 - benchmark/benchmark.set.js | 124 - benchmark/benchmark.set.length.js | 115 - benchmark/benchmark.to_string.js | 55 - benchmark/benchmark.to_string.length.js | 99 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 44 - index.mjs | 4 + index.mjs.map | 1 + lib/from_iterator.js | 48 - lib/from_iterator_map.js | 53 - lib/index.js | 106 - lib/main.js | 359 -- package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 51 files changed, 4870 insertions(+), 5467 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.instantiation.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.property_access.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/from_iterator.js delete mode 100644 lib/from_iterator_map.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 291f167..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:44:26.128Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index aa3bd2b..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/little-endian-factory) 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 65c8f87..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/little-endian-factory) 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 58a2043..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: '23 23 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -523,7 +514,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]. @@ -586,13 +577,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-little-endian-factory/main/LICENSE -[@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/wasm/memory]: https://github.com/stdlib-js/wasm-memory +[@stdlib/wasm/memory]: https://github.com/stdlib-js/wasm-memory/tree/esm -[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 86f84c5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 53ca74b..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.instantiation.js b/benchmark/benchmark.instantiation.js deleted file mode 100644 index dec39fe..0000000 --- a/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - 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 Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a8bfba3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 1dec0ac..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.property_access.js b/benchmark/benchmark.property_access.js deleted file mode 100644 index 9be0011..0000000 --- a/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index c98a89d..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 61df165..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randu = require( '@stdlib/random-array-randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 2084462..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3f8cfe1..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8aa32b0..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/little-endian-factory" -%% click B href "https://github.com/stdlib-js/array-little-endian-factory/tree/main" -%% click C href "https://github.com/stdlib-js/array-little-endian-factory/tree/production" -%% click D href "https://github.com/stdlib-js/array-little-endian-factory/tree/esm" -%% click E href "https://github.com/stdlib-js/array-little-endian-factory/tree/deno" -%% click F href "https://github.com/stdlib-js/array-little-endian-factory/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/little-endian-factory -[production-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/production -[deno-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 162e128..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var R=q(function(W,d){"use strict";function M(a){var e,u;for(e=[];u=a.next(),!u.done;)e.push(u.value);return e}d.exports=M});var x=q(function(X,_){"use strict";function F(a,e,u){var l,s,r;for(l=[],r=-1;s=a.next(),!s.done;)r+=1,l.push(e.call(u,s.value,r));return l}_.exports=F});var O=q(function(Z,S){"use strict";var L=require("@stdlib/assert-is-collection"),Y=require("@stdlib/assert-is-object"),g=require("@stdlib/assert-is-function"),k=require("@stdlib/assert-has-iterator-symbol-support"),A=require("@stdlib/symbol-iterator"),w=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/array-base-getter"),C=require("@stdlib/array-base-accessor-getter"),P=require("@stdlib/utils-inherit"),j=require("@stdlib/array-fixed-endian-factory"),N=require("@stdlib/ndarray-base-bytes-per-element"),V=require("@stdlib/string-base-capitalize"),c=require("@stdlib/string-format"),D=R(),H=x(),U=k(),T="little-endian",z={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},I={c:"a",f:"a",i:"an",u:"a",b:"a"};function G(a){return V(a)+"ArrayLE"}function J(a){var e,u,l,s;s=j(a),e=N(a),u=G(a),l=z[a];function r(){var n=arguments.length;return this instanceof r?(n===0?s.call(this,T):n===1?s.call(this,T,arguments[0]):n===2?s.call(this,T,arguments[0],arguments[1]):n===3&&s.call(this,T,arguments[0],arguments[1],arguments[2]),this):n===0?new r:n===1?new r(arguments[0]):n===2?new r(arguments[0],arguments[1]):new r(arguments[0],arguments[1],arguments[2])}return w(r,"BYTES_PER_ELEMENT",e),w(r,"name",u),w(r,"from",function(t){var o,b,v,m,f,E,p,h,i;if(!g(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!y(this))throw new TypeError(c("invalid invocation. `this` is not %s %s.",I[a[0]],u));if(b=arguments.length,b>1){if(v=arguments[1],!g(v))throw new TypeError(c("invalid argument. Second argument must be a function. Value: `%s`.",v));b>2&&(o=arguments[2])}if(L(t)){if(v){for(h=t.length,t.get&&t.set?p=C("default"):p=B("default"),m=new this(h),f=m._buffer,i=0;i\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\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\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @module @stdlib/array-little-endian-factory\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_main", "__commonJSMin", "exports", "module", "isCollection", "isObject", "isFunction", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "getter", "accessorGetter", "inherits", "fixedEndianFactory", "bytesPerElement", "capitalize", "format", "fromIterator", "fromIteratorMap", "HAS_ITERATOR_SYMBOL", "BYTE_ORDER", "DTYPE2SET", "CHAR2ARTICLE", "dtype2ctor", "dtype", "factory", "BYTES_PER_ELEMENT", "CTOR_NAME", "SETTER", "parent", "TypedArray", "nargs", "src", "thisArg", "clbk", "out", "buf", "tmp", "get", "len", "isTypedArrayConstructor", "args", "i", "value", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3b2058f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var logEach = require( '@stdlib/console-log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..642f144 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index c1adb5d..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c95efa..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array-little-endian-factory -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e55f89e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var getter = require( '@stdlib/array-base-getter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var inherits = require( '@stdlib/utils-inherit' ); -var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/package.json b/package.json index c767e8d..f8559db 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", "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", - "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", @@ -35,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-fixed-endian-factory": "github:stdlib-js/array-fixed-endian-factory#main", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-zero-to": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/console-log-each": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..29bb616 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 99d011d..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests From 15ea7ec437539cb77ba7f34b19155fd30b45968f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 00:38:50 +0000 Subject: [PATCH 12/14] Transform error messages --- lib/main.js | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/main.js b/lib/main.js index 478616c..e55f89e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -34,7 +34,7 @@ var inherits = require( '@stdlib/utils-inherit' ); var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var fromIterator = require( './from_iterator.js' ); var fromIteratorMap = require( './from_iterator_map.js' ); @@ -255,7 +255,7 @@ function factory( dtype ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); @@ -264,7 +264,7 @@ function factory( dtype ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -290,7 +290,7 @@ function factory( dtype ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { 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 ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -305,7 +305,7 @@ function factory( dtype ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -324,7 +324,7 @@ function factory( dtype ) { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isTypedArrayConstructor( this ) ) { throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); diff --git a/package.json b/package.json index d082868..c767e8d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-object": "^0.2.2", "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/symbol-iterator": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", From ddc8b85194d5798d079c29bc31f9ead925b243d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 00:39:57 +0000 Subject: [PATCH 13/14] Remove files --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 3 files changed, 4847 deletions(-) delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 642f144..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":";;wvCA2CA,IAAIA,EAAsBC,IACtBC,EAAa,gBACbC,EAAY,CACfC,QAAW,aACXC,QAAW,aACXC,MAAS,WACTC,MAAS,WACTC,OAAU,YACVC,OAAU,aAEPC,EAAe,CAClBC,EAAK,IACLC,EAAK,IACLC,EAAK,KACLC,EAAK,IACLC,EAAK,KAkGN,SAASC,EAASC,GACjB,IAAIC,EACAC,EACAC,EACAC,EAsBJ,SAASC,IACR,IAAIC,EAAQC,UAAUC,OACtB,OAAOC,gBAAgBJ,GAYR,IAAVC,EACJF,EAAOM,KAAMD,KAAMxB,GACE,IAAVqB,EACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,IACpB,IAAVD,EACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,GAAIA,UAAU,IAClC,IAAVD,GACXF,EAAOM,KAAMD,KAAMxB,EAAYsB,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAE/DE,MApBS,IAAVH,EACG,IAAID,EAEG,IAAVC,EACG,IAAID,EAAYE,UAAU,IAEnB,IAAVD,EACG,IAAID,EAAYE,UAAU,GAAIA,UAAU,IAEzC,IAAIF,EAAYE,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAY9D,CAuID,OAlLAH,EAASO,EAAoBX,GAE7BC,EAAoBW,EAAiBZ,GACrCE,EAvFD,SAAqBF,GACpB,OAAOa,EAAYb,GAAU,SAC9B,CAqFac,CAAYd,GACxBG,EAASjB,EAAWc,GAkDpBe,EAAaV,EAAY,oBAAqBJ,GAW9Cc,EAAaV,EAAY,OAAQH,GAkBjCa,EAAaV,EAAY,QAAQ,SAAeW,GAC/C,IAAIC,EACAX,EACAY,EACAC,EACAC,EACAC,EACAC,EACAC,EACA3B,EACJ,IAAM4B,EAAYf,MACjB,MAAM,IAAIgB,UAAWC,EAAO,WAE7B,IAAMC,EAAyBlB,MAC9B,MAAM,IAAIgB,UAAWC,EAAQ,2CAA4CjC,EAAcO,EAAM,IAAME,IAGpG,IADAI,EAAQC,UAAUC,QACL,EAAI,CAEhB,IAAMgB,EADNN,EAAOX,UAAW,IAEjB,MAAM,IAAIkB,UAAWC,EAAQ,SAAUR,IAEnCZ,EAAQ,IACZW,EAAUV,UAAW,GAEtB,CACD,GAAKqB,EAAcZ,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARAK,EAAMP,EAAIR,OAETc,EADIN,EAAIM,KAAON,EAAIa,IACbC,EAAgB,WAEhBC,EAAQ,WAGfX,GADAD,EAAM,IAAIV,KAAMc,IACNS,QACJpC,EAAI,EAAGA,EAAI2B,EAAK3B,IACrBwB,EAAKjB,GAAUP,EAAEK,EAAmBiB,EAAKR,KAAMO,EAASK,EAAKN,EAAKpB,GAAKA,IAAK,GAE7E,OAAOuB,CACP,CACD,OAAO,IAAIV,KAAMO,EACjB,CACD,GAAKiB,EAAUjB,IAASjC,GAAuByC,EAAYR,EAAKkB,IAAsB,CAErF,GADAd,EAAMJ,EAAKkB,MACLV,EAAYJ,EAAIe,MACrB,MAAM,IAAIV,UAAWC,EAAQ,SAAUV,IAUxC,IAPCK,EADIH,ECvQR,SAA0BkB,EAAIlB,EAAMD,GACnC,IAAIE,EACAkB,EACAzC,EAIJ,IAFAuB,EAAM,GACNvB,GAAK,IAEJyC,EAAID,EAAGD,QACAG,MAGP1C,GAAK,EACLuB,EAAIoB,KAAMrB,EAAKR,KAAMO,EAASoB,EAAEG,MAAO5C,IAExC,OAAOuB,CACR,CDwPUsB,CAAiBrB,EAAKF,EAAMD,GE1QtC,SAAuBmB,GACtB,IAAIjB,EACAkB,EAGJ,IADAlB,EAAM,KAELkB,EAAID,EAAGD,QACAG,MAGPnB,EAAIoB,KAAMF,EAAEG,OAEb,OAAOrB,CACR,CF+PUuB,CAActB,GAIrBA,GADAD,EAAM,IAAIV,KADVc,EAAMF,EAAIb,SAEAwB,QACJpC,EAAI,EAAGA,EAAI2B,EAAK3B,IACrBwB,EAAKjB,GAAUP,EAAEK,EAAmBoB,EAAKzB,IAAK,GAE/C,OAAOuB,CACP,CACD,MAAM,IAAIM,UAAWC,EAAQ,SAAUV,GACzC,IAcCD,EAAaV,EAAY,MAAM,WAC9B,IAAIsC,EACA/C,EACJ,IAAM4B,EAAYf,MACjB,MAAM,IAAIgB,UAAWC,EAAO,WAE7B,IAAMC,EAAyBlB,MAC9B,MAAM,IAAIgB,UAAWC,EAAQ,2CAA4CjC,EAAcO,EAAM,IAAME,IAGpG,IADAyC,EAAO,GACD/C,EAAI,EAAGA,EAAIW,UAAUC,OAAQZ,IAClC+C,EAAKJ,KAAMhC,UAAWX,IAEvB,OAAO,IAAIa,KAAMkC,EACnB,IAGCC,EAAUvC,EAAYD,GAEfC,EASP,SAASsB,EAAyBa,GACjC,OAASA,IAAUnC,CACnB,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29bb616..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 86d32c010e9d61f8cf959681d2c411267b78df4f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 00:40:19 +0000 Subject: [PATCH 14/14] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.from.js | 311 -- benchmark/benchmark.get.js | 62 - benchmark/benchmark.instantiation.js | 253 - benchmark/benchmark.js | 48 - benchmark/benchmark.of.js | 74 - benchmark/benchmark.property_access.js | 127 - benchmark/benchmark.set.js | 124 - benchmark/benchmark.set.length.js | 115 - benchmark/benchmark.to_string.js | 55 - benchmark/benchmark.to_string.length.js | 99 - branches.md | 56 - dist/index.js | 19 - dist/index.js.map | 7 - examples/index.js | 44 - index.mjs | 4 + index.mjs.map | 1 + lib/from_iterator.js | 48 - lib/from_iterator_map.js | 53 - lib/index.js | 106 - lib/main.js | 359 -- package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 35 - 51 files changed, 4870 insertions(+), 5467 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.instantiation.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.property_access.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 branches.md delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 examples/index.js create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/from_iterator.js delete mode 100644 lib/from_iterator_map.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 17cb05a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-02T00:36:07.322Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index aa3bd2b..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/little-endian-factory) 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 65c8f87..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/little-endian-factory) 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 58a2043..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: '23 23 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -523,7 +514,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]. @@ -586,13 +577,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-little-endian-factory/main/LICENSE -[@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/wasm/memory]: https://github.com/stdlib-js/wasm-memory +[@stdlib/wasm/memory]: https://github.com/stdlib-js/wasm-memory/tree/esm -[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes +[@stdlib/array/typed-dtypes]: https://github.com/stdlib-js/array-typed-dtypes/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.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 86f84c5..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 53ca74b..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.instantiation.js b/benchmark/benchmark.instantiation.js deleted file mode 100644 index dec39fe..0000000 --- a/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - 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 Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a8bfba3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 1dec0ac..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.property_access.js b/benchmark/benchmark.property_access.js deleted file mode 100644 index 9be0011..0000000 --- a/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - 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.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index c98a89d..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( '@stdlib/array-float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( 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( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index 61df165..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var randu = require( '@stdlib/random-array-randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 2084462..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3f8cfe1..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var zeroTo = require( '@stdlib/array-zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8aa32b0..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/little-endian-factory" -%% click B href "https://github.com/stdlib-js/array-little-endian-factory/tree/main" -%% click C href "https://github.com/stdlib-js/array-little-endian-factory/tree/production" -%% click D href "https://github.com/stdlib-js/array-little-endian-factory/tree/esm" -%% click E href "https://github.com/stdlib-js/array-little-endian-factory/tree/deno" -%% click F href "https://github.com/stdlib-js/array-little-endian-factory/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/little-endian-factory -[production-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/production -[deno-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-little-endian-factory/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-little-endian-factory/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 162e128..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var q=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var R=q(function(W,d){"use strict";function M(a){var e,u;for(e=[];u=a.next(),!u.done;)e.push(u.value);return e}d.exports=M});var x=q(function(X,_){"use strict";function F(a,e,u){var l,s,r;for(l=[],r=-1;s=a.next(),!s.done;)r+=1,l.push(e.call(u,s.value,r));return l}_.exports=F});var O=q(function(Z,S){"use strict";var L=require("@stdlib/assert-is-collection"),Y=require("@stdlib/assert-is-object"),g=require("@stdlib/assert-is-function"),k=require("@stdlib/assert-has-iterator-symbol-support"),A=require("@stdlib/symbol-iterator"),w=require("@stdlib/utils-define-nonenumerable-read-only-property"),B=require("@stdlib/array-base-getter"),C=require("@stdlib/array-base-accessor-getter"),P=require("@stdlib/utils-inherit"),j=require("@stdlib/array-fixed-endian-factory"),N=require("@stdlib/ndarray-base-bytes-per-element"),V=require("@stdlib/string-base-capitalize"),c=require("@stdlib/string-format"),D=R(),H=x(),U=k(),T="little-endian",z={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},I={c:"a",f:"a",i:"an",u:"a",b:"a"};function G(a){return V(a)+"ArrayLE"}function J(a){var e,u,l,s;s=j(a),e=N(a),u=G(a),l=z[a];function r(){var n=arguments.length;return this instanceof r?(n===0?s.call(this,T):n===1?s.call(this,T,arguments[0]):n===2?s.call(this,T,arguments[0],arguments[1]):n===3&&s.call(this,T,arguments[0],arguments[1],arguments[2]),this):n===0?new r:n===1?new r(arguments[0]):n===2?new r(arguments[0],arguments[1]):new r(arguments[0],arguments[1],arguments[2])}return w(r,"BYTES_PER_ELEMENT",e),w(r,"name",u),w(r,"from",function(t){var o,b,v,m,f,E,p,h,i;if(!g(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!y(this))throw new TypeError(c("invalid invocation. `this` is not %s %s.",I[a[0]],u));if(b=arguments.length,b>1){if(v=arguments[1],!g(v))throw new TypeError(c("invalid argument. Second argument must be a function. Value: `%s`.",v));b>2&&(o=arguments[2])}if(L(t)){if(v){for(h=t.length,t.get&&t.set?p=C("default"):p=B("default"),m=new this(h),f=m._buffer,i=0;i\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\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\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @module @stdlib/array-little-endian-factory\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var factory = require( '@stdlib/array-little-endian-factory' );\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_from_iterator", "__commonJSMin", "exports", "module", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_main", "__commonJSMin", "exports", "module", "isCollection", "isObject", "isFunction", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "setReadOnly", "getter", "accessorGetter", "inherits", "fixedEndianFactory", "bytesPerElement", "capitalize", "format", "fromIterator", "fromIteratorMap", "HAS_ITERATOR_SYMBOL", "BYTE_ORDER", "DTYPE2SET", "CHAR2ARTICLE", "dtype2ctor", "dtype", "factory", "BYTES_PER_ELEMENT", "CTOR_NAME", "SETTER", "parent", "TypedArray", "nargs", "src", "thisArg", "clbk", "out", "buf", "tmp", "get", "len", "isTypedArrayConstructor", "args", "i", "value", "main"] -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 3b2058f..0000000 --- a/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( '@stdlib/array-float64' ); -var logEach = require( '@stdlib/console-log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..642f144 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-fixed-endian-factory@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/string-base-capitalize@v0.3.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";var p=r(),u="little-endian",j={float64:"setFloat64",float32:"setFloat32",int32:"setInt32",int16:"setInt16",uint32:"setUint32",uint16:"setUint16"},c={c:"a",f:"a",i:"an",u:"a",b:"a"};function v(r){var v,b,g,w;function x(){var t=arguments.length;return this instanceof x?(0===t?w.call(this,u):1===t?w.call(this,u,arguments[0]):2===t?w.call(this,u,arguments[0],arguments[1]):3===t&&w.call(this,u,arguments[0],arguments[1],arguments[2]),this):0===t?new x:1===t?new x(arguments[0]):2===t?new x(arguments[0],arguments[1]):new x(arguments[0],arguments[1],arguments[2])}return w=a(r),v=m(r),b=function(t){return h(t)+"ArrayLE"}(r),g=j[r],i(x,"BYTES_PER_ELEMENT",v),i(x,"name",b),i(x,"from",(function(i){var d,a,m,h,u,j,w,x,E;if(!s(this))throw new TypeError(f("null01"));if(!y(this))throw new TypeError(f("invalid invocation. `this` is not %s %s.",c[r[0]],b));if((a=arguments.length)>1){if(!s(m=arguments[1]))throw new TypeError(f("null2H",m));a>2&&(d=arguments[2])}if(t(i)){if(m){for(x=i.length,w=i.get&&i.set?l("default"):o("default"),u=(h=new this(x))._buffer,E=0;E\n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'null2J', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( format('null01') );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n"],"names":["HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","BYTE_ORDER","DTYPE2SET","float64","float32","int32","int16","uint32","uint16","CHAR2ARTICLE","c","f","i","u","b","factory","dtype","BYTES_PER_ELEMENT","CTOR_NAME","SETTER","parent","TypedArray","nargs","arguments","length","this","call","fixedEndianFactory","bytesPerElement","capitalize","dtype2ctor","setReadOnly","src","thisArg","clbk","out","buf","tmp","get","len","isFunction","TypeError","format","isTypedArrayConstructor","isCollection","set","accessorGetter","getter","_buffer","isObject","ITERATOR_SYMBOL","next","it","v","done","push","value","fromIteratorMap","fromIterator","args","inherits"],"mappings":"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"} \ No newline at end of file diff --git a/lib/from_iterator.js b/lib/from_iterator.js deleted file mode 100644 index c1adb5d..0000000 --- a/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/from_iterator_map.js b/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354..0000000 --- a/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c95efa..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array-little-endian-factory -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var factory = require( '@stdlib/array-little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index e55f89e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert-is-collection' ); -var isObject = require( '@stdlib/assert-is-object' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var getter = require( '@stdlib/array-base-getter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var inherits = require( '@stdlib/utils-inherit' ); -var fixedEndianFactory = require( '@stdlib/array-fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var capitalize = require( '@stdlib/string-base-capitalize' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/package.json b/package.json index c767e8d..f8559db 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", "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", - "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", @@ -35,52 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-fixed-endian-factory": "github:stdlib-js/array-fixed-endian-factory#main", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-object": "^0.2.2", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/string-base-capitalize": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/symbol-iterator": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-zero-to": "^0.2.2", - "@stdlib/assert-is-arraybuffer": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/console-log-each": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-array-randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..29bb616 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 99d011d..0000000 --- a/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests