From 35dffe0c223c663d5ca9764cc57ac082daebea3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 7 Feb 2023 01:59:26 +0000 Subject: [PATCH 01/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..f91dd5f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( 'null36', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 191f607..55b7f97 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" From c3c181cf82f23b6b70a4b21032ff53d0490dd517 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 7 Feb 2023 02:01:12 +0000 Subject: [PATCH 02/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 60 +- stats.html | 6177 +++++++++++++++++++++ test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 38 files changed, 6198 insertions(+), 4042 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..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 `tslint.json` files: -[tslint.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 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 9c440b6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 f034dd4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -246,7 +239,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index b26a371..419ab6e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..00a41db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("null36",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c09df97 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'null36', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,SAAUL,IAMxC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 f91dd5f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'null36', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 55b7f97..920abcd 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,8 @@ "version": "0.0.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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": { - "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", @@ -35,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..cc7c7d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From d50d26dbf4e0843c5dd5e82cbccc4b44b159c55e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Feb 2023 01:51:20 +0000 Subject: [PATCH 03/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..f91dd5f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( 'null36', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 552df82..8115bd0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" From d307ecabc24eb86dc9c5d3b334de334f05d67b6d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Feb 2023 01:51:50 +0000 Subject: [PATCH 04/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 419ab6e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 00a41db..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("null36",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c09df97..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'null36', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,SAAUL,IAMxC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cc7c7d3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2938a1078990be9d14ee031ab18fb16b5316abbc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Feb 2023 01:53:17 +0000 Subject: [PATCH 05/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 38 files changed, 6198 insertions(+), 4043 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..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 `tslint.json` files: -[tslint.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 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 9c440b6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 f034dd4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -246,7 +239,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index b26a371..419ab6e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..00a41db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("null36",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c09df97 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'null36', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,SAAUL,IAMxC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 f91dd5f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'null36', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 8115bd0..920abcd 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..41335aa --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 8976f560bc4b07eb3232607f7f92ad391afa21ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Feb 2023 18:30:32 +0000 Subject: [PATCH 06/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..f91dd5f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( 'null36', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 2e6bc8d..1c6e00d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" From d5a404eafc27d63784d86126d82fb50411c669a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Feb 2023 18:31:11 +0000 Subject: [PATCH 07/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 419ab6e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 2.0 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 00a41db..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("null36",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c09df97..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'null36', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,SAAUL,IAMxC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 41335aa..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 21042fb510d4a34d1242a8a2fbaa4ddcf436cf9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Feb 2023 18:32:14 +0000 Subject: [PATCH 08/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 38 files changed, 6198 insertions(+), 4047 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..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 `tslint.json` files: -[tslint.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 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 9c440b6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 f034dd4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -246,7 +239,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index b26a371..419ab6e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..00a41db --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("null36",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c09df97 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'null36', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,SAAUL,IAMxC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 f91dd5f..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'null36', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 1c6e00d..27feadc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..20413ed --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 8068a5bb73ed062f29f109d532e1fc5754b04f35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 27 Feb 2023 18:32:50 +0000 Subject: [PATCH 09/98] Update README.md for ESM bundle v0.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0568ee..b38b278 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.0.1-esm/index.mjs'; ``` @@ -159,7 +159,7 @@ v = arr.get( 4 ); - - - - From 3ec37a4ed72a927d6c9e66ba5cb91889d5dc0434 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:33:26 +0000 Subject: [PATCH 13/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 41 files changed, 6198 insertions(+), 4053 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 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..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 `tslint.json` files: -[tslint.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 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 9c440b6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 f034dd4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -246,7 +239,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fbd060a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0a90e6f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 1c6e00d..27feadc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/random-base-randu": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..c38e8a1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From b10f63536c81123437da00fd1dac4342251f2219 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:02:25 +0000 Subject: [PATCH 14/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..36637a6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u,F5', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index eb40fb0..5cac0a0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.0" From bc7d1b53f9057182bc9f74938e180a090ea1411b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:31:59 +0000 Subject: [PATCH 15/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fbd060a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0a90e6f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;2fAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c38e8a1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8019b1a1aa2873f01141f136ab43ac4af1a9e544 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:33:00 +0000 Subject: [PATCH 16/98] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 42 files changed, 6198 insertions(+), 4088 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 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +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' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +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' - uses: styfle/cancel-workflow-action@0.11.0 - 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 9c440b6..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +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: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +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 the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 f034dd4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/upload-artifact@v3 - 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' - uses: distributhor/workflow-webhook@v3 - 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 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +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' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - 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' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # 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' - uses: actions/setup-node@v3 - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ad09b21 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..23266a2 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ygBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 5cac0a0..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..67d5a16 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From fd3866f157c63b8e81db0751d20dc08832b55cf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:45:12 +0000 Subject: [PATCH 17/98] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21d816f..22affb1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.1.0-esm/index.mjs'; ``` @@ -170,7 +170,7 @@ v = arr.get( 4 ); - - - - From 8de2167b5101098c9db96c69e106378401f2b0b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:20:36 +0000 Subject: [PATCH 21/98] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 99 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 6198 insertions(+), 4246 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5319ecb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:28:49.988Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 e5128f8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2511a18 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..dfde7f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 152b87f..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..e97a977 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 5d70965..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 02ac168245718d8777f07a9300ef7eb0a33b93e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:07:55 +0000 Subject: [PATCH 22/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..36637a6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u,F5', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 948c278..6e65d71 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From ef8188fee442cfe2210c1609a6851f6101166bb7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:33:25 +0000 Subject: [PATCH 23/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2511a18..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index dfde7f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e97a977..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c6a2dc4a28e472c193e59ba46b22947a72084329 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:36:17 +0000 Subject: [PATCH 24/98] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 99 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 43 files changed, 6198 insertions(+), 4245 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 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 e5128f8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4858375 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..dfde7f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 6e65d71..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..378faeb --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 5d70965..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 8b5655f30de0c61bb095d830a63d074c31e1c3e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:51:28 +0000 Subject: [PATCH 25/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..36637a6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u,F5', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 6505627..ac11ecb 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From 3ca8ea0629c8cb99c69169e4a0e4302c844f1583 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:40:32 +0000 Subject: [PATCH 26/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4858375..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index dfde7f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 378faeb..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7f77a79fa2822b9b0e0ee682912509c0a72e2b49 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:44:01 +0000 Subject: [PATCH 27/98] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 6198 insertions(+), 4188 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 474347e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:48:51.559Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 e5128f8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c5ef600..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -// tslint:disable:no-unused-expression - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4858375 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..dfde7f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index ac11ecb..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..f15d443 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 5eb46cb353daf894681e9d945c76bce4440c8900 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:21:11 +0000 Subject: [PATCH 28/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..36637a6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u,F5', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 399870e..d9f6326 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From 92c64aa73fa756c207a18c9f202bb8aa5a5e0063 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:47:09 +0000 Subject: [PATCH 29/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4858375..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index dfde7f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f15d443..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 18ea9f191a976949415a1692fba730a899e76458 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:49:45 +0000 Subject: [PATCH 30/98] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 43 files changed, 6198 insertions(+), 4187 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 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +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 `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 e5128f8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4858375 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..dfde7f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index d9f6326..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..cf72ca8 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 757b27fff1a74f32e95ce61e02a4e6f31ed94681 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:58:19 +0000 Subject: [PATCH 31/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..36637a6 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u,F5', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index bee9739..88fa182 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From a55708bd749693c7b174f8bc450f6ddee41dadbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:16:27 +0000 Subject: [PATCH 32/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4858375..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index dfde7f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cf72ca8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 914796931eb8bdc8ca57257bea20bf73055d32b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:19:42 +0000 Subject: [PATCH 33/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 6198 insertions(+), 4183 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index cd1b815..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:53:23.006Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 ab56cca..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 c1c45e7..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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 e5128f8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - 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 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - 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 + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index b6cf387..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4858375 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..dfde7f8 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 36637a6..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u,F5', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 88fa182..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "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..d132b1d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 946184f8230e9f5bfa7aff81fa1ad079154639e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:18:44 +0000 Subject: [PATCH 34/98] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d9f991..2c4d23c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From 2373b6bb9f3d8e162d41fdb58198366f17e72d5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:58:08 +0000 Subject: [PATCH 35/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4858375..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u,F5",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index dfde7f8..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u,F5', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,WAAYL,IAM1C,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d132b1d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ea995640bcc0bf63af993a158c8c1a6cbf5087e3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:58:38 +0000 Subject: [PATCH 36/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 33 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 6198 insertions(+), 4189 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 87dd12e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:22:12.643Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b5be18a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -257,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1dad638..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bd033da --- /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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(t){var e;if(!(this instanceof n))return new n(t);if(!r(t))throw new TypeError(i("invalid argument. Must provide an array-like object. Value: `%s`.",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(n,"name","AccessorArray"),t(n.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(n.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(n.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fdf6774 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/string-format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ugBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,oEAAqEL,IAMnG,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 62425e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 2c4d23c..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.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..c7c2124 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 4e408d4a6a3abbd1f51f77ab360eb97901a4ebea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:53:09 +0000 Subject: [PATCH 37/98] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d9f991..2c4d23c 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" From 406b75b176f387d859078d07a9bba9fee8e41fca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:14:31 +0000 Subject: [PATCH 38/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bd033da..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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(t){var e;if(!(this instanceof n))return new n(t);if(!r(t))throw new TypeError(i("invalid argument. Must provide an array-like object. Value: `%s`.",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(n,"name","AccessorArray"),t(n.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(n.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(n.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fdf6774..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/string-format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ugBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,oEAAqEL,IAMnG,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c7c2124..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf4bfe6e35038917d8e05fb60e2c8e51bcf1a609 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:14:47 +0000 Subject: [PATCH 39/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 6198 insertions(+), 4194 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6385ebd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:13:47.225Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index b5be18a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bd033da --- /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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(t){var e;if(!(this instanceof n))return new n(t);if(!r(t))throw new TypeError(i("invalid argument. Must provide an array-like object. Value: `%s`.",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(n,"name","AccessorArray"),t(n.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(n.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(n.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fdf6774 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/string-format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ugBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,oEAAqEL,IAMnG,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 62425e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 2c4d23c..05459d1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.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..7603e92 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From d7a8d5fbfeea9d92f08734b4ab4ce9d192a0a7cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:51:20 +0000 Subject: [PATCH 40/98] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab82309..6356500 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.0", "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.0" From 1692d312ea933f6ebd8407c58a84516fc245d89c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:35:11 +0000 Subject: [PATCH 41/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6327 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bd033da..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/utils-define-nonenumerable-read-write-accessor@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(t){var e;if(!(this instanceof n))return new n(t);if(!r(t))throw new TypeError(i("invalid argument. Must provide an array-like object. Value: `%s`.",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(n,"name","AccessorArray"),t(n.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(n.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(n.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fdf6774..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/string-format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ugBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,oEAAqEL,IAMnG,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7603e92..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 31e1bc3a2c57d0027501f8e6c536796d7d933029 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:36:18 +0000 Subject: [PATCH 42/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 6198 insertions(+), 4197 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 5b4a805..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bf77ba9 --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(t){var e;if(!(this instanceof n))return new n(t);if(!r(t))throw new TypeError(i("invalid argument. Must provide an array-like object. Value: `%s`.",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(n,"name","AccessorArray"),t(n.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(n.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(n.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fdf6774 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/string-format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ugBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,oEAAqEL,IAMnG,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 62425e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 6356500..46871b6 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "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,40 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/assert-has-own-property": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..33c9028 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 670f2ab9f5052b59bbf67e14b76543f5599ea524 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:55:23 +0000 Subject: [PATCH 43/98] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb9736a..2457520 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.2.0-esm/index.mjs'; ``` @@ -170,7 +170,7 @@ v = arr.get( 4 ); - - - - From a70189d9eb7bf4fb1551f725ad93b4126efab776 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:22:50 +0000 Subject: [PATCH 47/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 4863 insertions(+), 4192 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e718237 --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 66aec6f..fb9648b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9348688 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 7b394db28c8a541ee8e017498b48da86a0f25459 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:37:14 +0000 Subject: [PATCH 48/98] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90497e6..02af0e3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.2.1-esm/index.mjs'; ``` @@ -170,7 +170,7 @@ v = arr.get( 4 ); - - - - From d4d0fd9d6f5b6b7aec63e4ad75fb310dd0e56977 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 14:15:38 +0000 Subject: [PATCH 52/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 4863 insertions(+), 4197 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2769e76..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:56:34.370Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..97c2fef --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 32db3c9..fb9648b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/random-base-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.1" - }, - "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..a80eafd --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 263ff9511e6223d1029fbf9776b0bc40999b6f65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:41:35 +0000 Subject: [PATCH 53/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index c656669..32db3c9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.1", "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.1", From ed2173cbea8dfc4221d6acffdce434c741c97851 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:29:28 +0000 Subject: [PATCH 54/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 97c2fef..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/utils-define-nonenumerable-read-write-accessor@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a80eafd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e1a7f4d3ad3a95b646a4ffa4a51ddfaeb745af7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 10:29:42 +0000 Subject: [PATCH 55/98] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 4863 insertions(+), 4198 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..97c2fef --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 32db3c9..fb9648b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/random-base-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.1" - }, - "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..a80eafd --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 65ecdd6ab2431627960420a7ec2972e5905231b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:04:03 +0000 Subject: [PATCH 56/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 1fbd2e8..eede2a5 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.1", "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", From a22328af8c5183245d2e907f9a8498c09714e854 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:09:57 +0000 Subject: [PATCH 57/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 97c2fef..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/utils-define-nonenumerable-read-write-accessor@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a80eafd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 68b4e6e2a6a2c87e0df5b294877daa243b242978 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:10:11 +0000 Subject: [PATCH 58/98] 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 | 125 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 4863 insertions(+), 4331 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.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 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fe3d241 --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index eede2a5..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-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..6e06d9d --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From ec07a4a783c9c6d4c4bff5f2d993e02a9f30c6d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 12:10:55 +0000 Subject: [PATCH 59/98] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9678bbc..3df0d9d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.2.2-esm/index.mjs'; ``` @@ -170,7 +170,7 @@ v = arr.get( 4 ); - - - - From 838a349498679317eddb1ee0f79d5298e9e34493 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 14:03:24 +0000 Subject: [PATCH 63/98] 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 | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 44 files changed, 4863 insertions(+), 4364 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.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 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2a4553b --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 8eaa92a..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-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..7af6b67 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 8d16c3f7ff7d661ca84862c455d9ab0bb9e409d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:31:10 +0000 Subject: [PATCH 64/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index cfd7286..64c93d8 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.2", "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", From 5078d25941c1a07ed24dee0bec586f0668fa746c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:47:04 +0000 Subject: [PATCH 65/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2a4553b..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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7af6b67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 12dbd61763cedf2f6d1ab9bc77a980bafb6be674 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:47:17 +0000 Subject: [PATCH 66/98] 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 | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4470 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.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 5706ff8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:59:32.381Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 291c8a6..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2a4553b --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 64c93d8..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-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..7af6b67 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From aa5008c0c059f75debb68f886c6fdf14bde7fed5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:00:33 +0000 Subject: [PATCH 67/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index cfd7286..64c93d8 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.2", "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", From 4b1e9336eb9fa426f2d32c4682755620400d5207 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:59:53 +0000 Subject: [PATCH 68/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2a4553b..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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7af6b67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c7d3b75b11f097f4d1644b28f1a1d10099d5aacb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 02:00:10 +0000 Subject: [PATCH 69/98] 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 | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 126 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4473 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.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 e2ebbda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T00:59:16.192Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index db35859..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..62380a8 --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 64c93d8..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-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..7af6b67 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index af774ab..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From de2bbfbcd3045e74c70ad6a865f9d6c1086a1671 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Dec 2025 09:58:52 +0000 Subject: [PATCH 70/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index cfd7286..64c93d8 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.2", "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", From 1d10aa8d458bdb42115998553c6bb333fe094bd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Dec 2025 09:59:14 +0000 Subject: [PATCH 71/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 62380a8..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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7af6b67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5343d689890f0fb5611b1b8c9ddf912421bb5c15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Dec 2025 09:59:50 +0000 Subject: [PATCH 72/98] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 4863 insertions(+), 4482 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # 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 + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..62380a8 --- /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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 64c93d8..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-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..7af6b67 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 7f286a43e74c9c5d08ed662f6e61a7f5ea211945 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:39:05 +0000 Subject: [PATCH 73/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index bee25e3..3e9cd1a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.2", "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", From f61275ac3d407dba86eefecb136122e6693ef32b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:37:55 +0000 Subject: [PATCH 74/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 62380a8..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/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7af6b67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e02bf32140956c286100d8da8decac7f829a658e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:38:12 +0000 Subject: [PATCH 75/98] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 4863 insertions(+), 4582 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7333c7d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index 3e9cd1a..8e1eb1e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7af6b67 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From d62100d2c10a96273e1d39d1b9c32aad7e11a86b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:03:52 +0000 Subject: [PATCH 76/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 08392f2..a463520 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.2", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From 16e959015d3d93946d3db3c879e88e395fc430f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:52:18 +0000 Subject: [PATCH 77/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7333c7d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7af6b67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 009be92ec890860f5537d1017eb43d997e74d0a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:52:52 +0000 Subject: [PATCH 78/98] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 45 files changed, 4863 insertions(+), 4575 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e4de16f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index a463520..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d76d78e --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 8eac30ab30a0929f94c6fcfad3bb29ae86188b83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:00:48 +0000 Subject: [PATCH 79/98] Update README.md for ESM bundle v0.2.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69e623b..ed8ec0c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@esm/index.mjs'; +import AccessorArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor@v0.2.3-esm/index.mjs'; ``` @@ -170,7 +170,7 @@ v = arr.get( 4 ); - - - - From db59b11bf1023ddc2bff4261813c016936eba0fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 04:18:50 +0000 Subject: [PATCH 83/98] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4576 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.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 1787742..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T01:59:09.641Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7160b27 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index b44e4b4..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fd9537 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From b54f7597108342efb388295a5a2daa85cacff393 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 02:02:06 +0000 Subject: [PATCH 84/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 649f9e2..b44e4b4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.3", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From 68e08009a9c459f7ec9cb8a04949d862686a616a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 03:17:28 +0000 Subject: [PATCH 85/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7160b27..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fd9537..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 841b0917a1b5530ad3ef9447901716987d240809 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Mar 2026 03:17:55 +0000 Subject: [PATCH 86/98] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4587 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1b34d6c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-23T01:36:09.116Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7160b27 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index b44e4b4..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fd9537 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 6f606f23f8ae7ef2a554338744ccb74fb5d020cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 03:57:05 +0000 Subject: [PATCH 87/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 649f9e2..b44e4b4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.3", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From 0de9ab133a4bb906dfb3467d32d6f749e46bcd67 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 04:40:20 +0000 Subject: [PATCH 88/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7160b27..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fd9537..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2e0f2b2ffe8e6c05cb410761e1e05ad2d45b1dd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 04:40:38 +0000 Subject: [PATCH 89/98] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4587 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c7ec5c1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-11T03:40:18.696Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7160b27 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index b44e4b4..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fd9537 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From c363d10b45f505cf51abf14d06b5f68bd18ee1c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:23:16 +0000 Subject: [PATCH 90/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index 649f9e2..b44e4b4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.3", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From c57b9b55e3bd55b9b0d01fac83aa3f59e923427b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:24:06 +0000 Subject: [PATCH 91/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7160b27..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fd9537..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b527bc018f72da241a46788537693e892d55ed57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:24:22 +0000 Subject: [PATCH 92/98] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4605 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 761e5e5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-23T03:21:41.290Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e080b98..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){return e||t((e={exports:{}}).exports,e),e.exports}};var n=u(function(v,i){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),s=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}s(r,"name","AccessorArray");c(r.prototype,"length",_,g);s(r.prototype,"get",function(e){return this._getter(this._buffer,e)});s(r.prototype,"set",function(e,o){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,o,e)});i.exports=r -});var p=n();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 38fad16..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\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,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7160b27 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index b44e4b4..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fd9537 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 7235a9f6b8dc554599fec52718ace2b299374be7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:23:54 +0000 Subject: [PATCH 93/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index f5da471..c7b57a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.3", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From 51aa94a22159e20459b0b8e4d19422f0e6134720 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:25:37 +0000 Subject: [PATCH 94/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7160b27..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fd9537..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 86d90357b61adcad59bd3166a011c2b8daa41b27 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:25:59 +0000 Subject: [PATCH 95/98] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4605 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b24a4b4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-03T03:19:35.595Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7dca930..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(s){throw (e=0, s)}};};var o=u(function(v,n){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}i(r,"name","AccessorArray");c(r.prototype,"length",_,g);i(r.prototype,"get",function(e){return this._getter(this._buffer,e)});i(r.prototype,"set",function(e,s){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,s,e)});n.exports=r -});var p=o();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1d16a55..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7160b27 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..74615c6 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index c7b57a3..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8fd9537 --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); From 7b278627a958580a1a41b9e93dfb563bcf18dfd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:52:18 +0000 Subject: [PATCH 96/98] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 62425e3..8c700e3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -26,7 +26,7 @@ var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-wri var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var accessors = require( '@stdlib/array-base-accessors' ); var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // FUNCTIONS // @@ -75,7 +75,7 @@ function AccessorArray( arr ) { return new AccessorArray( arr ); } if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); + throw new TypeError( format( '1Yn2u', arr ) ); } o = accessors( arr ); this._buffer = arr; diff --git a/package.json b/package.json index f5da471..c7b57a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/array-base-accessors": "^0.2.3", "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", From 5bb1d50512e8b9ae29573dc110b0ead55b084ecc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:58:03 +0000 Subject: [PATCH 97/98] Remove files --- index.d.ts | 145 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4992 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c9bf774..0000000 --- a/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7160b27..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 74615c6..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;ghBAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8fd9537..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ddddcbff657ae12c623455341d14640fb944d367 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:58:28 +0000 Subject: [PATCH 98/98] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 162 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 127 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 86 - docs/types/test.ts | 131 - examples/index.js | 67 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 43 - lib/main.js | 164 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.get.js | 54 - test/test.js | 99 - test/test.set.js | 69 - 46 files changed, 4863 insertions(+), 4606 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.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.get.js delete mode 100644 test/test.js delete mode 100644 test/test.set.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index db55df1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-21T03:38:40.507Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c60390..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 7fc4510..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor) 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 132fb7f..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '55 19 * * 2' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -259,7 +250,7 @@ printArray( 'dense', dense ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 82eb217..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-base-randu' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:length', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:set', pkg ), function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index eb2d62d..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor" -%% click B href "https://github.com/stdlib-js/array-base-accessor/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-accessor/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-accessor/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-accessor/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-accessor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor -[production-url]: https://github.com/stdlib-js/array-base-accessor/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-accessor/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-accessor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-accessor/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-accessor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-accessor/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-accessor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7dca930..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var u=function(t,e){return function(){try{return e||t((e={exports:{}}).exports,e),e.exports}catch(s){throw (e=0, s)}};};var o=u(function(v,n){ -var c=require('@stdlib/utils-define-nonenumerable-read-write-accessor/dist'),i=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/array-base-accessors/dist'),a=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function g(t){this._buffer.length=t}function _(){return this._buffer.length}function r(t){var e;if(!(this instanceof r))return new r(t);if(!a(t))throw new TypeError(h('1Yn2u',t));return e=f(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}i(r,"name","AccessorArray");c(r.prototype,"length",_,g);i(r.prototype,"get",function(e){return this._getter(this._buffer,e)});i(r.prototype,"set",function(e,s){if(arguments.length<2){this._setter(this._buffer,0,e);return}this._setter(this._buffer,s,e)});n.exports=r -});var p=o();module.exports=p; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1d16a55..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar accessors = require( '@stdlib/array-base-accessors' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nmodule.exports = AccessorArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Create a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @module @stdlib/array-base-accessor\n*\n* @example\n* var AccessorArray = require( '@stdlib/array-base-accessor' );\n*\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAuB,QAAS,wDAAyD,EACzFC,EAAc,QAAS,uDAAwD,EAC/EC,EAAY,QAAS,8BAA+B,EACpDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAW9C,SAASC,EAAWC,EAAM,CACzB,KAAK,QAAQ,OAASA,CACvB,CAQA,SAASC,GAAY,CACpB,OAAO,KAAK,QAAQ,MACrB,CAoBA,SAASC,EAAeC,EAAM,CAC7B,IAAIC,EACJ,GAAK,EAAE,gBAAgBF,GACtB,OAAO,IAAIA,EAAeC,CAAI,EAE/B,GAAK,CAACN,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWL,EAAQ,oEAAqEK,CAAI,CAAE,EAEzG,OAAAC,EAAIR,EAAWO,CAAI,EACnB,KAAK,QAAUA,EACf,KAAK,QAAUC,EAAE,UAAW,CAAE,EAC9B,KAAK,QAAUA,EAAE,UAAW,CAAE,EACvB,IACR,CAeAT,EAAaO,EAAe,OAAQ,eAAgB,EASpDR,EAAsBQ,EAAc,UAAW,SAAUD,EAAWF,CAAU,EAkB9EJ,EAAaO,EAAc,UAAW,MAAO,SAAcG,EAAM,CAChE,OAAO,KAAK,QAAS,KAAK,QAASA,CAAI,CACxC,CAAC,EAwBDV,EAAaO,EAAc,UAAW,MAAO,SAAcI,EAAOD,EAAM,CACvE,GAAK,UAAU,OAAS,EAAI,CAC3B,KAAK,QAAS,KAAK,QAAS,EAAGC,CAAM,EACrC,MACD,CACA,KAAK,QAAS,KAAK,QAASD,EAAKC,CAAM,CACxC,CAAC,EAKDb,EAAO,QAAUS,IC9HjB,IAAIK,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setReadWriteAccessor", "setReadOnly", "accessors", "isCollection", "format", "setLength", "len", "getLength", "AccessorArray", "arr", "o", "idx", "value", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9a07585..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index b3cf22b..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bc8d0bb..0000000 --- a/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 71b73be..c9bf774 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1950ed2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-write-accessor@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(t){var e;if(!(this instanceof i))return new i(t);if(!r(t))throw new TypeError(n("1Yn2u",t));return e=s(t),this._buffer=t,this._getter=e.accessors[0],this._setter=e.accessors[1],this}e(i,"name","AccessorArray"),t(i.prototype,"length",(function(){return this._buffer.length}),(function(t){this._buffer.length=t})),e(i.prototype,"get",(function(t){return this._getter(this._buffer,t)})),e(i.prototype,"set",(function(t,e){arguments.length<2?this._setter(this._buffer,0,t):this._setter(this._buffer,e,t)}));export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0970826 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils-define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport accessors from '@stdlib/array-base-accessors';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( '1Yn2u', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n"],"names":["AccessorArray","arr","o","this","isCollection","TypeError","format","accessors","_buffer","_getter","_setter","setReadOnly","setReadWriteAccessor","prototype","length","len","idx","value","arguments"],"mappings":";;6eAuEA,SAASA,EAAeC,GACvB,IAAIC,EACJ,KAAOC,gBAAgBH,GACtB,OAAO,IAAIA,EAAeC,GAE3B,IAAMG,EAAcH,GACnB,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAMvC,OAJAC,EAAIK,EAAWN,GACfE,KAAKK,QAAUP,EACfE,KAAKM,QAAUP,EAAEK,UAAW,GAC5BJ,KAAKO,QAAUR,EAAEK,UAAW,GACrBJ,IACR,CAeAQ,EAAaX,EAAe,OAAQ,iBASpCY,EAAsBZ,EAAca,UAAW,UA3D/C,WACC,OAAOV,KAAKK,QAAQM,MACrB,IAZA,SAAoBC,GACnBZ,KAAKK,QAAQM,OAASC,CACvB,IAqFAJ,EAAaX,EAAca,UAAW,OAAO,SAAcG,GAC1D,OAAOb,KAAKM,QAASN,KAAKK,QAASQ,EACpC,IAwBAL,EAAaX,EAAca,UAAW,OAAO,SAAcI,EAAOD,GAC5DE,UAAUJ,OAAS,EACvBX,KAAKO,QAASP,KAAKK,QAAS,EAAGS,GAGhCd,KAAKO,QAASP,KAAKK,QAASQ,EAAKC,EAClC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index e11080d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array-base-accessor -* -* @example -* var AccessorArray = require( '@stdlib/array-base-accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// 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 8c700e3..0000000 --- a/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils-define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( '1Yn2u', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/package.json b/package.json index c7b57a3..939dcd3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,41 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-assert-is-accessor-array": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7c7871d --- /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.get.js b/test/test.get.js deleted file mode 100644 index 524f199..0000000 --- a/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 93ab4d1..0000000 --- a/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 29fb2f4..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -});